Home >Database >Mysql Tutorial >SQLServer跨数据库服务器查询

SQLServer跨数据库服务器查询

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 15:15:051257browse

应用场景: 主要用在分布式 查询 的存储过程或执行插入更新等连库与操作语句中 1.创建链接 服务器 sp_addlinkedserver exec sp_addlinkedserver @server= 'SQLSvr136', @srvproduct= '', @provider='SQLNCLI', @datasrc = '192.168.85.136' 2.登录链接 服务

应用场景:
主要用在分布式查询的存储过程或执行插入更新等连库与操作语句中

1.创建链接服务器 sp_addlinkedserver

exec sp_addlinkedserver @server= 'SQLSvr136', @srvproduct= '', @provider='SQLNCLI', @datasrc = '192.168.85.136'


2.登录链接服务器 sp_addlinkedsrvlogin
exec sp_addlinkedsrvlogin @rmtsrvname = 'SQLSvr136',@useself = 'false ', @locallogin = null, @rmtuser ='sa', @rmtpassword = 'smssdev'


测试是否成功
exec sp_testlinkedserver SQLSvr136


3.查询
select * from SQLSvr136.ECSS_Monitor.dbo.HardwareInfo


4.删除连接
exec sp_dropserver @server= 'SQLSvr136',@droplogins = 'droplogins'


详细参数含义参考:http://msdn.microsoft.com/zh-cn/library/ms190479.aspx

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn