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

SQLServer跨数据库服务器查询

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:15:05
Original
1262 people have browsed it

应用场景: 主要用在分布式 查询 的存储过程或执行插入更新等连库与操作语句中 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'
Copy after login


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


测试是否成功
exec sp_testlinkedserver SQLSvr136
Copy after login


3.查询
select * from SQLSvr136.ECSS_Monitor.dbo.HardwareInfo
Copy after login


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


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

source:php.cn
Statement of this Website
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
Latest Issues
Problem with tp6 connecting to sqlserver database
From 1970-01-01 08:00:00
0
0
0
Unable to connect to SQL Server in Laravel
From 1970-01-01 08:00:00
0
0
0
Methods of parsing MYD, MYI, and FRM files
From 1970-01-01 08:00:00
0
0
0
SQLSTATE: User login failed
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template