不错呦!smile@林凯西,确保“准备文件”中的几个文件都有安装,S...您好,看了您这篇帖子觉得很有帮助。但是有个问题想请...我的修改过了怎么还被恶意注册呢 @jjjjiiii 用PJ快9年了,主要是A...PJ3啊,貌似很少有人用PJ了,现在不是WP就是z...@332347365,我当时接入时错误码没有-10...楼主,ChkValue值应为-103是什么意思呢?...大哥 你最近能看到我发的信息,请跟我联系,我有个制...
SQL Server 2008分布式查询示例
编辑:dnawo 日期:2013-02-17
1.使用链接服务器
2.使用特定名称及特定数据源
若执行查询出错,提示:
引用内容
使用下边语句开启/关闭Ad Hoc Distributed Queries组件:
参考资料
[1].MSSQl分布式查询:http://www.cnblogs.com/chenkai/archive/2010/09/09/1822305.html
复制内容到剪贴板
程序代码

--创建链接服务器
exec sp_addlinkedserver @server='testdb', @srvproduct='', @provider='SQLOLEDB', @datasrc='192.168.0.111'
--更新链接服务器登录映射
exec sp_addlinkedsrvlogin @rmtsrvname='testdb', @useself='false', @locallogin=null, @rmtuser='sa', @rmtpassword='sa123456'
--查看链接服务器信息
select name,product,provider,data_source,query_timeout,lazy_schema_validation,is_remote_login_enabled,is_rpc_out_enabled from sys.servers where is_linked=1
--执行查询
select top 10 * from testdb.Northwind.dbo.Customers
--删除链接服务器登录映射
exec sp_droplinkedsrvlogin @rmtsrvname='testdb', @locallogin=null
--删除链接服务器
exec sp_dropserver @server='testdb'
exec sp_addlinkedserver @server='testdb', @srvproduct='', @provider='SQLOLEDB', @datasrc='192.168.0.111'
--更新链接服务器登录映射
exec sp_addlinkedsrvlogin @rmtsrvname='testdb', @useself='false', @locallogin=null, @rmtuser='sa', @rmtpassword='sa123456'
--查看链接服务器信息
select name,product,provider,data_source,query_timeout,lazy_schema_validation,is_remote_login_enabled,is_rpc_out_enabled from sys.servers where is_linked=1
--执行查询
select top 10 * from testdb.Northwind.dbo.Customers
--删除链接服务器登录映射
exec sp_droplinkedsrvlogin @rmtsrvname='testdb', @locallogin=null
--删除链接服务器
exec sp_dropserver @server='testdb'
2.使用特定名称及特定数据源
复制内容到剪贴板
程序代码

select top 10 * from opendatasource('SQLOLEDB','Data Source=192.168.0.111;User ID=sa;Password=sa123456').Northwind.dbo.Customers
若执行查询出错,提示:

SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的 STATEMENT 'OpenRowset/OpenDatasource' 的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。系统管理员可以通过使用 sp_configure 启用 'Ad Hoc Distributed Queries'。有关启用 'Ad Hoc Distributed Queries' 的详细信息,请参阅 SQL Server 联机丛书中的 "外围应用配置器"。
使用下边语句开启/关闭Ad Hoc Distributed Queries组件:
复制内容到剪贴板
程序代码

--开启Ad Hoc Distributed Queries组件
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
--关闭Ad Hoc Distributed Queries组件
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
--关闭Ad Hoc Distributed Queries组件
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure
参考资料
[1].MSSQl分布式查询:http://www.cnblogs.com/chenkai/archive/2010/09/09/1822305.html
评论: 0 | 引用: 0 | 查看次数: 3735
发表评论
请登录后再发表评论!