Connect from one instance to another via T-SQL ,SQL 2000

  • 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

  • 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


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply