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 dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

T-SQL Change Database

Status
Not open for further replies.

mateobus

Programmer
Aug 20, 2007
28
US
Hey all, I am writing my first migration script to transfer some data from one db to another one. I am wondering if there is a line of tsql that you can use to switch between the different dbs. Thanks in advance.

 
in moving from one db to another I personally prefer to simply use the fully qualified name.

insert db1.dbo.test (field1, field2)
select field1, field2 from db2.dbo.test

if on differnt servers , set up linked servers fist and then add the servername as well
insert server1.db1.dbo.test (field1, field2)
select field1, field2 from server2.db2.dbo.test

"NOTHING is more important in a database than integrity." ESquared
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top