Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 copy Table

Author  Topic 

kurtgr
Starting Member

25 Posts

Posted - 2009-06-23 : 12:02:56
Hello all I would like to copy a table and it contents from one database to another. Can someone tell me which is the best way in achieving this?

Thanks in advance

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-23 : 12:04:18
select * INTO database2..table from database1..table


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

kurtgr
Starting Member

25 Posts

Posted - 2009-06-23 : 12:27:57
Thanks for your answer but would this be after i have created the table structure in the other database?

Thnks again in advance
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-23 : 12:30:33
No.
This kind of insert requires that the destination table does NOT exist.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

kurtgr
Starting Member

25 Posts

Posted - 2009-06-23 : 12:44:55
Ok Thanks again it worked
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-23 : 12:51:24
welcome


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-06-24 : 02:04:30
Note that if you want to have indices in the target table, generate script;create table;copy table

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -