Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying Table Between Databases

Status
Not open for further replies.
Aug 22, 2003
5
0
0
GB
I want to copy an entire table with all its data and references to overwrite an existing table of the same name in another db. (They are both in the same instance of SQL server).I have fiddled around dropping foreign keys, deleting exiting data and then using DTS. Found that it did not copy an identity spec on the key field.

Can anyone describe an easier and more reliable way.

Thanking you in hope,

Mike.
 
You'll need to use scripts to drop the forign keys, truncate the destincation table, enable identity insert (look in BOL for more info on this), then use T/SQL to insert the data then recreate the forign keys.

Denny
MCSA (2003) / MCDBA (SQL 2000) / MCTS (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top