Wednesday, March 7, 2012

copying a table from one database to another

Hey

in query analyzer, how do you copy a table form one db to another db

i thort it was something like

select * into dbo.databaseA.tableNew from dbo.databaseB.tableOld

cheers

insert into databaseA..tableNewselect *From databaseb..tableOld
|||

The difference between SELECT INTO and INSERT INTO is that with INSERT the table must already exist. SELECT INTO creates a new table.

Your original query looked okay, assuming that you wanted a new table tableNew. What error were you getting? You might also have a permissions problem since you are going from one database to another.

Don

|||

hey

yeah... thats why i 'd like to use select into or otherwise i'll have to create the other table ( not as fast )

when i try to run

select * into dbo.databaseA.tableNew from dbo.databaseB.tableOld

i get

Server: Msg 208, Level 16, State 1, Line 1
Invalid object name dbo.databaseB.tableOld

i've tripple checked the spelling and tried the same thing with other databases on other computers and got the same error so i'm sure its not a permission error or anything, must be syntax

cheers

|||Use this:select * into databaseA..tableNew from databaseB..tableOld|||

Matt-dot-net:

Use this:select * into databaseA..tableNew from databaseB..tableOld

<groan> I HATE when I miss things like that!

Don

|||

cheers bruva, just what i needed

No comments:

Post a Comment