September 2, 2010 at 6:26 am
Hi All,
I would like to connect to one SQL instance from the current SQL instance that I am working on now. The reason is , I want to load data from one SQL Server Instance to another SQL Server Instance using SQL statements like
insert into table1
select * from table2
--table1 resides on SQLInstance1
--table2 resides on SQLInstance2
Both instances are SQL Server 2000 instances
I want to execute this operation via the T-SQL code.
What is the T-SQL command to execute this?
Thanks in Advance
September 2, 2010 at 8:09 am
it's fairly easy; you just need to add a linked server, and then select using 4 part naming conventions:
EXEC master.dbo.sp_addlinkedserver @server = N'ANOTHERSERVER\INSTANCENAME', @srvproduct=N'SQL Server'
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname = N'ANOTHERSERVER\INSTANCENAME', @locallogin = NULL , @useself = N'True'
insert into table1
select X.*
from [ANOTHERSERVER\INSTANCENAME].Databasename.dbo.table2 X
Lowell
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply