隐藏

ql2008向sql2000链接(OPENDATASOURCE)时错误解决方法

发布:2014/12/16 11:22:05作者:管理员 来源:本站 浏览次数:1427

本机环境
Windowx Server 2008 R2 Enterprise x64 SP1
Sql Server 2008 x64
服务器环境
Windows Server 2003 Enterprise x32
Sql Server 2000 x32 SP4
在使用OPENDATASOURCE语句时,提示
SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的 STATEMENT'OpenRowset/OpenDatasource' 的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。系统管理员可以通过使用 sp_configure 启用 'Ad Hoc Distributed Queries'。有关启用 '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

SELECT *
FROM OPENDATASOURCE(
  'SQLOLEDB',
  'Data Source=ServerName;User ID=sa;Password=sa'
).DataBaseName.dbo.Table
再次运行OPENDATASOURCE时提示
sql2008链接服务器null的ole db访问接口sqlncli10返回了消息 "未指定的错误"
或者"在该服务器上找不到完成该操作所需的存储过程。 请与系统管理员联系。"
查询相关资料,找到解决方法:
官方的文档地址:
http://support.microsoft.com/?scid=kb%3Bzh-cn%3B906954&x=12&y=8
在SqlServer2000的SP4补丁的安装文件中找到instcat.sql文件(安装盘\SQL2KSP4\install\instcat.sql)大小大概是935k。
开始-运行-cmd
键入命令:
osql -U "账户" -P "密码" -S "服务器名称或IP地址" -i "安装盘\SQL2KSP4\install\instcat.sql"
回车,出现哗哗哗的一幕,最后提示成功!