linked servers in MS SQL

EXEC sp_addlinkedserver @server='LKSRV_SYS', @srvproduct = 'SQLServer OLEDB Provider', @provider = 'SQLOLEDB', @datasrc ='SERVERNAMEHERE'
EXEC sp_addlinkedsrvlogin 'LKSRV_SYS', 'False', 'sa', 'sa', 'SA PASSWORD HERE'
GO

And if you get any errors running the above, because users are associated with the linked server then run this:
sp_dropserver 'LKSRV_SYS', 'droplogins'

Advertisements