Home > Database > Mysql Tutorial > SQl 跨服务器查询语句

SQl 跨服务器查询语句

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:59:17
Original
1464 people have browsed it

SQl跨服务器查询的二种实现方法,一般情况如果安全设置好了,根本无法用,不过内部网络还是不错的。

select * from OPENDATASOURCE(
'SQLOLEDB',
'Data Source=远程ip;User ID=sa;Password=密码'
).库名.dbo.表名

insert 本地库名..表名 select * from OPENDATASOURCE(
'SQLOLEDB',
'Data Source=远程ip;User ID=sa;Password=密码'
).库名.dbo.表名

或使用联结服务器:
--创建linkServer
exec sp_addlinkedserver '别名','','SQLOLEDB','192.168.2.5'

--登陆linkServer
exec sp_addlinkedsrvlogin '别名','false',null,'sa','1234'

--查询
select * from 别名.库名.dbo.表名

--以后不再使用时删除链接服务器
exec sp_dropserver '别名','droplogins'
Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template