October 4, 2007 at 6:14 am
Hi,
How do I copy a table from one database to another on the same server?
Without losing the keys and depencies?
Both database are exactly the same.
October 4, 2007 at 7:07 am
There must be different degrees of "exactly the same" otherwise you wouldn't need to do this...
Seriously, though, just script out the table and then run the script against the second database. Then use the tool of your choice to copy the data across (DTS, an INSERT query, etc).
John
October 4, 2007 at 7:19 am
Ya of course your right the data is not the same.
What do you mean by scripting out?
October 4, 2007 at 7:28 am
I'm not clear about whether your table already exists in the second database and you just want to copy the data. If so, just use DTS or INSERT INTO or whatever. If you need to create the table first, right-click on the table in the first database is Enterprise Manager, choose Generate SQL Script, and choose your options in the dialog box. You can then run the resulting script against the second database to create the table there. I think there's also a DTS task that will copy the whole table over for you as well, if you prefer to use that method.
John
October 4, 2007 at 7:34 am
O.k i did the script and run it against the second databse. It created an empty table. I will try the wizard right now.
But that erase the primary key and dependencies. Is there a way to keep those or am I just dreaming.
October 4, 2007 at 7:59 am
There are lots of options in that dialog box, one of which is to script out the primary key constraint. Have a play with those options, and see if you can get it to generate the script you want.
John
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply