Copy Data from One SQL Instance to Another

February 3rd, 2009 by Sameer | Filed under Uncategorized.

When using SQL Server Management Studio you might want to copy data from one DB to another (using just a SELECT and INSERT statement)

It’s so easy you won’t believe it

sp_addlinkedserver @server='192.168.123.456', @provider='SQLNCLI',    @srvproduct='',@provstr='User Id=sa; Password=are-you-crazy-to-use-sa'

insert into [192.168.123.456].MYDB.dbo.tblRecords

select * from MYDB.dbo.tblRecords

and when you are done

sp_dropserver  [192.168.123.456]

References:
sp_addlinkedserver on MSDN

sp_dropserver on MSDN

Other Interesting Posts

2 Responses to “Copy Data from One SQL Instance to Another”

  1. abhijit says:

    error :(

    Msg 208, Level 16, State 1, Line 4
    Invalid object name ‘BuiltUP.dbo.tblRecords’.

  2. abhijit says:

    sp_addlinkedserver @server=’192.168.2.134′, @provider=’SQLNCLI’,
    @srvproduct=”,@provstr=’User Id=sa; Password=saptech@123′

    insert into [192.168.2.134].BuiltUP.dbo.tblRecords

    select * from BuiltUP.dbo.tblRecords

Leave a Reply