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

 

5 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

  3. Alex says:

    Please tell me thats not your real sa password

Leave a Reply

Your email address will not be published. Required fields are marked *

*


+ 8 = 9

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>