MSSQL2005访问MSSQL2000的表

test88666 2014-09-29 03:13:02
如题,我想要在MSSQL2005里面用SELECT 语句访问MSSQL2000,不知道该怎么做?
...全文
252 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
习惯性蹭分 2014-10-04
  • 打赏
  • 举报
回复
ying2734 2014-10-02
  • 打赏
  • 举报
回复
学习学习
还在加载中灬 2014-09-29
  • 打赏
  • 举报
回复
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
 GO
 
select * from OPENDATASOURCE ('SQLOLEDB','DataSource=192.168.30.196;User ID=sa;Password=').master.dbo.spt_values
 
 
 GO
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure 
要用GO 隔开
引用 8 楼 test88666 的回复:
[quote=引用 7 楼 ky_min 的回复:] [quote=引用 6 楼 test88666 的回复:] [quote=引用 5 楼 ky_min 的回复:] 如果是连接另外一个数据库,如同 #2的 应该是这样
select * from OPENDATASOURCE ('SQLOLEDB','DataSource=*.*.*.*;User ID=username;Password=password').master.dbo.[table1]
不过,在使用openrowset/opendatasource前搜先要启用Ad Hoc Distributed Queries服务,因为这个服务不安全所以SqlServer默认是关闭的 启用Ad Hoc Distributed Queries的方法 执行下面的查询语句就可以了:
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
使用完毕后,记得一定要要关闭它,因为这是一个安全隐患,切记执行下面的SQL语句
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure 
如果想详细的了解,参考以下 http://www.cnblogs.com/OpenCoder/archive/2010/03/18/1689321.html
执行之后有下面的提示:
Msg 15281, Level 16, State 1, Line 8
SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', see "Surface Area Configuration" in SQL Server Books Online. 
[/quote]
引用 5 楼 ky_min 的回复:
不过,在使用openrowset/opendatasource前搜先要启用Ad Hoc Distributed Queries服务,因为这个服务不安全所以SqlServer默认是关闭的 启用Ad Hoc Distributed Queries的方法 执行下面的查询语句就可以了:
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
呃,有开启吗 我上面说了[/quote] 我是这样输入的:
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure


select * from OPENDATASOURCE ('SQLOLEDB','DataSource=192.168.30.196;User ID=sa;Password=').master.dbo.spt_values



exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure 
然后就有那个错误了。[/quote]
test88666 2014-09-29
  • 打赏
  • 举报
回复
引用 7 楼 ky_min 的回复:
[quote=引用 6 楼 test88666 的回复:] [quote=引用 5 楼 ky_min 的回复:] 如果是连接另外一个数据库,如同 #2的 应该是这样
select * from OPENDATASOURCE ('SQLOLEDB','DataSource=*.*.*.*;User ID=username;Password=password').master.dbo.[table1]
不过,在使用openrowset/opendatasource前搜先要启用Ad Hoc Distributed Queries服务,因为这个服务不安全所以SqlServer默认是关闭的 启用Ad Hoc Distributed Queries的方法 执行下面的查询语句就可以了:
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
使用完毕后,记得一定要要关闭它,因为这是一个安全隐患,切记执行下面的SQL语句
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure 
如果想详细的了解,参考以下 http://www.cnblogs.com/OpenCoder/archive/2010/03/18/1689321.html
执行之后有下面的提示:
Msg 15281, Level 16, State 1, Line 8
SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', see "Surface Area Configuration" in SQL Server Books Online. 
[/quote]
引用 5 楼 ky_min 的回复:
不过,在使用openrowset/opendatasource前搜先要启用Ad Hoc Distributed Queries服务,因为这个服务不安全所以SqlServer默认是关闭的 启用Ad Hoc Distributed Queries的方法 执行下面的查询语句就可以了:
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
呃,有开启吗 我上面说了[/quote] 我是这样输入的:
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure


select * from OPENDATASOURCE ('SQLOLEDB','DataSource=192.168.30.196;User ID=sa;Password=').master.dbo.spt_values



exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure 
然后就有那个错误了。
还在加载中灬 2014-09-29
  • 打赏
  • 举报
回复
引用 6 楼 test88666 的回复:
[quote=引用 5 楼 ky_min 的回复:] 如果是连接另外一个数据库,如同 #2的 应该是这样
select * from OPENDATASOURCE ('SQLOLEDB','DataSource=*.*.*.*;User ID=username;Password=password').master.dbo.[table1]
不过,在使用openrowset/opendatasource前搜先要启用Ad Hoc Distributed Queries服务,因为这个服务不安全所以SqlServer默认是关闭的 启用Ad Hoc Distributed Queries的方法 执行下面的查询语句就可以了:
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
使用完毕后,记得一定要要关闭它,因为这是一个安全隐患,切记执行下面的SQL语句
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure 
如果想详细的了解,参考以下 http://www.cnblogs.com/OpenCoder/archive/2010/03/18/1689321.html
执行之后有下面的提示:
Msg 15281, Level 16, State 1, Line 8
SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', see "Surface Area Configuration" in SQL Server Books Online. 
[/quote]
引用 5 楼 ky_min 的回复:
不过,在使用openrowset/opendatasource前搜先要启用Ad Hoc Distributed Queries服务,因为这个服务不安全所以SqlServer默认是关闭的 启用Ad Hoc Distributed Queries的方法 执行下面的查询语句就可以了:
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
呃,有开启吗 我上面说了
test88666 2014-09-29
  • 打赏
  • 举报
回复
引用 5 楼 ky_min 的回复:
如果是连接另外一个数据库,如同 #2的 应该是这样
select * from OPENDATASOURCE ('SQLOLEDB','DataSource=*.*.*.*;User ID=username;Password=password').master.dbo.[table1]
不过,在使用openrowset/opendatasource前搜先要启用Ad Hoc Distributed Queries服务,因为这个服务不安全所以SqlServer默认是关闭的 启用Ad Hoc Distributed Queries的方法 执行下面的查询语句就可以了:
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
使用完毕后,记得一定要要关闭它,因为这是一个安全隐患,切记执行下面的SQL语句
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure 
如果想详细的了解,参考以下 http://www.cnblogs.com/OpenCoder/archive/2010/03/18/1689321.html
执行之后有下面的提示:
Msg 15281, Level 16, State 1, Line 8
SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', see "Surface Area Configuration" in SQL Server Books Online. 
还在加载中灬 2014-09-29
  • 打赏
  • 举报
回复
如果是连接另外一个数据库,如同 #2的 应该是这样
select * from OPENDATASOURCE ('SQLOLEDB','DataSource=*.*.*.*;User ID=username;Password=password').master.dbo.[table1]
不过,在使用openrowset/opendatasource前搜先要启用Ad Hoc Distributed Queries服务,因为这个服务不安全所以SqlServer默认是关闭的 启用Ad Hoc Distributed Queries的方法 执行下面的查询语句就可以了:
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
使用完毕后,记得一定要要关闭它,因为这是一个安全隐患,切记执行下面的SQL语句
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure 
如果想详细的了解,参考以下 http://www.cnblogs.com/OpenCoder/archive/2010/03/18/1689321.html
test88666 2014-09-29
  • 打赏
  • 举报
回复
引用 1 楼 ky_min 的回复:
可以直接查的 你是说连接MSSQL2000的数据库吗
直接 SELECT * FROM TABLE 这种访问。
test88666 2014-09-29
  • 打赏
  • 举报
回复
引用 2 楼 dotnetstudio 的回复:
IP填你2000库的IP

OPENDATASOURCE ('SQLOLEDB','DataSource=102.56.5.1;User ID=sa;Password=123').master.dbo.[table1]
select * from table1
你的有下面的提示: incorrect syntax near the keyword 'OPENDATASOURCE '
KeepSayingNo 2014-09-29
  • 打赏
  • 举报
回复
IP填你2000库的IP

OPENDATASOURCE ('SQLOLEDB','DataSource=102.56.5.1;User ID=sa;Password=123').master.dbo.[table1]
select * from table1
还在加载中灬 2014-09-29
  • 打赏
  • 举报
回复
可以直接查的 你是说连接MSSQL2000的数据库吗

34,575

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧