SQL Server跨数据库访问数据
星期四 2015年12月3日 王佳明 技术 数据库 0人
SQL Server跨数据库访问数据
使用代码如下:
select * from openrowset('SQLOLEDB','数据库IP';'用户名';'密码', 数据库名称.dbo.表名)
如果提示:
SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的 STATEMENT'OpenRowset/OpenDatasource' 的访问。
1.开启Ad Hoc Distributed Queries组件,在sql查询编辑器中执行如下语句:
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
2.关闭Ad Hoc Distributed Queries组件,在sql查询编辑器中执行如下语句:
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure
本站内容多数为佳明one原创,少量转载自网络。
- 本文标题:SQL Server跨数据库访问数据
- 本文地址:https://itjm.com/2015/12/638.html
