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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 inserting data from another database

Author  Topic 

TerryNL
Starting Member

21 Posts

Posted - 2008-03-26 : 11:16:37
hi there,

i have two databases
now i want to insert data in to the second database from the first database..
what is the right way to do that?

thanks

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-03-26 : 11:20:36
If both databases are on the same server:

insert into db2.dbo.table
select col1, col2,... from db1.dbo.table


If they are on different servers, add second server as linked server:

insert into server2.db2.dbo.table
select col1, col2,... from db1.dbo.table




Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-03-26 : 13:10:20
Or use OPENROWSET() function to insert them if they are on diffrent servers.
Go to Top of Page

TerryNL
Starting Member

21 Posts

Posted - 2008-03-28 : 10:19:44
thanks for the replies
it works :)
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2008-03-29 : 08:03:14
There is also SSIS as an option of managing the data flow

Jack Vamvas
--------------------
Search IT jobs from multiple sources- http://www.ITjobfeed.com
Go to Top of Page
   

- Advertisement -