国内最全IT社区平台 联系我们 | 收藏本站
华晨云阿里云优惠2
您当前位置:首页 > 数据库 > Sqlserver > SQL Server 跨域查询(权限、语句、过程)

SQL Server 跨域查询(权限、语句、过程)

来源:程序员人生   发布时间:2014-01-04 14:18:54 阅读次数:2721次
1.开通分布式查询权限

exec sp_configure 'show advanced options',1
reconfigure

exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure

2.查询

select * from
openrowset( 'SQLOLEDB ', 'IP地址(服务器名)'; '用户名'; '密码',[数据库名].[dbo].[表名]) a
, openrowset( 'SQLOLEDB ', 'IP地址(服务器名)'; '用户名'; '密码',[数据库名].[dbo].[表名]) b
where *** GROUP by *** order by count(1) desc

3.然后换查询条件,然后修改IP、 库名和表名。

4.关闭

exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure

生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠
程序员人生
------分隔线----------------------------
分享到:
------分隔线----------------------------
关闭
程序员人生