示例:
--创建链接服务器
exec sp_addlinkedserver 'srv_lnk ', ' ', 'SQLOLEDB ', '远程服务器名或ip地址 '
exec sp_addlinkedsrvlogin 'srv_lnk ', 'false ',null, '用户名 ', '密码 '
go
--查询示例
select from srv_lnk数据库名dbo表名
--修改链接服务器
if exists(select 1 from mastersysservers where srvname='srv_lnk')
exec sp_dropserver 'srv_lnk','droplogins'
exec sp_addlinkedserver 'srv_lnk','','SQLOLEDB','abc'
exec sp_addlinkedsrvlogin 'srv_lnk','false',null,'sa','sa'
如:
if exists(select 1 from mastersysservers where srvname='SUNRISE')
exec sp_dropserver 'SUNRISE','droplogins'
exec sp_addlinkedserver 'SUNRISE','','SQLOLEDB','17216224247'
exec sp_addlinkedsrvlogin 'SUNRISE','false',null,'sa','tvshopper2004'
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)