添加链接服务器 SQL SERVER
使用sql语句:
exec sp_addlinkedserver @server='serverontest',@provider='sqloledb',@srvproduct='',@datasrc='101.123.10.112'
添加一个链接服务器
使用sql语句:
EXEC sp_addlinkedsrvlogin @rmtsrvname = 'serverontest', @useself = 'false', @locallogin = 'sa', @rmtuser = 'sa', @rmtpassword = 'passwordofsa'
添加登录方式
exec sp_addlinkedserver @server='linkDB',@provider='sqloledb',@srvproduct='',@datasrc='*.*.*.*' EXEC sp_addlinkedsrvlogin @rmtsrvname = 'linkDB', @useself = 'false', @locallogin = 'sa', @rmtuser = 'sa', @rmtpassword = 'password'
select * from sys.linked_logins select * from sys.servers
select top 100 * from linkDB.DB_Name.dbo.Table_Name