Exec sp_droplinkedsrvlogin DataBaseServerAlias,Null
Exec sp_dropserver DataBaseServerAlias
EXEC sp_addlinkedserver
@server='DataBaseServerAlias',--被访问的服务器别名
@srvproduct='',
@provider='SQLOLEDB',
@datasrc='Server2' --要访问的服务器
EXEC sp_addlinkedsrvlogin
@rmtsrvname = 'DataBaseServerAlias', --被访问的服务器别名
@useself = 'false',
@locallogin = NULL,
@rmtuser = 'sa', --帐号
@rmtpassword = 'thankyoubobby' --密码
Select * from DataBaseServerAlias.pubs.dbo.orders
参考网址:
http://msdn.microsoft.com/en-us/library/ms190479(SQL.90).aspx
http://msdn.microsoft.com/en-us/library/aa259581(SQL.80).aspx