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)
 Query - Data from two different server

Author  Topic 

zefiros
Starting Member

16 Posts

Posted - 2008-05-21 : 04:39:59
Hi, is it possible to connect to two different databases relying on different servers?
I want to do the following

INSERT INTO [LIBRARY].[dbo].MTMCH ([MCH_CODE])
SELECT MCH_CODE
FROM [UTILS].[dbo].[HLP_MTMCH]

I know that this works for two databases on the same server, how it would be the syntax if [LIBRARY] was on server [A] and [UTILS] on server [B] ?
Many Thanks!

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2008-05-21 : 04:48:05
Use sp_addlinkedserver to add a linked server, then you can do:

Insert into table (<fieldlist>) (on local server)
select <fieldlist>
from Linkedserver.database.owner.table
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-21 : 05:34:34
Or use OPENROWSET() function
Go to Top of Page
   

- Advertisement -