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.
| Author |
Topic |
|
landau66
Yak Posting Veteran
61 Posts |
Posted - 2007-12-07 : 04:33:05
|
| Hi everyone!I want to copy from DB certain tables to an other DB. How can I do that with SQL Server 2005. I would prefer an SQL string solution instead of buttonclicking solution. Thanks a lot and greetings from Vienna, Austrialandau |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2007-12-07 : 04:46:15
|
| create the table in the second DB. If it is not on the same server, you will need to create a linked server, you can use sp_addlinkedserver for this. Afcter this is done, you can just do:Insert into Table (<fieldlist>)select <fieldlist>from Table |
 |
|
|
suresha_b
Yak Posting Veteran
82 Posts |
Posted - 2007-12-07 : 04:53:29
|
| use AnotherDBgoselect * into dbo.TableName from DB.dbo.TableName |
 |
|
|
landau66
Yak Posting Veteran
61 Posts |
Posted - 2007-12-07 : 04:53:40
|
| The DB is on the same server. It contains about 25 tables. Do I have to create all this tables by hand in the new DB?? Or do I have a copy function or anything like that??Thanks for your quick answerlandau |
 |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2007-12-07 : 05:16:17
|
| Not if you do not want to, you can use suresha_bs suggestion. |
 |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2007-12-07 : 23:40:55
|
| suresha_bs' way doesn't copy index nor keys. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-12-10 : 01:40:16
|
quote: Originally posted by landau66 The DB is on the same server. It contains about 25 tables. Do I have to create all this tables by hand in the new DB?? Or do I have a copy function or anything like that??Thanks for your quick answerlandau
Generate the script of the tables and run it in target dband then do Insert into...select ....MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|