Sql Server 2005读取外部数据的方法
作者:Rimifon 来源:風雲工作室 时间:2008-07-08 19:08:00
SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的 STATEMENT'OpenRowset/OpenDatasource' 的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。系统管理员可以通过使用 sp_configure 启用 'Ad Hoc Distributed Queries'。
有关启用 'Ad Hoc Distributed Queries' 的详细信息,请参阅 SQL Server 联机丛书中的 "外围应用配置器"。
1)启用外部数据访问
sp_configure 'show advanced options',1
reconfigure
sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
2)读取外部数据:
select * from OpenDataSource('SqlNCli',
'server=169.254.0.1;uid=sa;pwd=******'
).Rimifon.dbo.T_City
使用链接服务器的方法:
sp_addLinkedServer '169.254.0.1'
go
sp_addLinkedsrvLogin '169.254.0.1', false, null, 'sa', '******'
go
select * from OpenQuery([169.254.0.1],
'select * from Rimifon.dbo.T_Prov')
go
sp_DropServer [169.254.0.1],DropLogins
go
或者:
sp_addLinkedServer 'MyServer', '', 'SqlNCli', '', '',
'Server=169.254.0.1;Database=Rimifon'
go
sp_addLinkedsrvLogin 'MyServer', false, null, 'sa', '******'
go
select * from OpenQuery(MyServer, 'select * from T_Prov')
go
sp_DropServer MyServer,DropLogins
go
使用OpenRowSet的方式:
select * from openrowset('SqlNCli',
'Server=169.254.0.1;Database=Rimifon;UID=sa;PWD=******',
'select * from T_Prov')
从外部数据库复制表结构和数据过来:
select * into Test.dbo.T_Prov from OpenDataSource('SqlNCli',
'Server=169.254.0.1;UID=sa;PWD=******'
).Rimifon.dbo.T_Prov
标签:sql,server,sql,数据库
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
用ASP设计购物车
2008-04-17 13:52:00
MySQL:使用源码分发版还是二进制分发版
2009-09-01 10:35:00
jQuery 1.3.3 新功能[译]
2009-06-04 12:23:00
将一个图片以二进制值的形式存入Xml文件中
2008-09-04 11:24:00
关于设计的一些个人看法
2008-06-12 12:44:00
获取一个数字的个位、十位、百位的函数代码
2011-02-20 11:06:00
IBatis.net连接MySql 问题与故障的解决方案
2011-06-02 09:38:00
ASP3.0中的流控制能力
2008-10-19 17:41:00
如何定义记录集打开的游标类型?
2009-11-15 20:19:00
Asp下Access无法更新的解决方法
2012-12-04 20:19:35
Oracle数据操作和控制语言详解
2008-01-16 19:18:00
小三角的做法与使用
2008-10-08 10:25:00
![](https://img.aspxhome.com/file/uploadpic/20071/200713110649890.gif)
Update 语句
2009-06-22 12:52:00
操作Dom节点实现间歇滚动新闻
2009-10-16 20:51:00
Mysql入门系列:MySQL数据目录的位置
2008-11-24 12:59:00
![](https://img.aspxhome.com/file/UploadPic/200811/20081129183226513.jpg)
MySQL 5数据库连接超时问题
2009-12-29 10:23:00
P3P 和 跨域 (cross-domain) cookie 访问(读取和设置)
2011-04-02 10:42:00
三分钟学会Sql Server的复制功能[图]
2008-07-18 12:18:00
![](https://img.aspxhome.com/file/UploadPic/20087/18/2008718122618221s.gif)
xhtml+css VS div+css
2008-04-07 13:00:00
再谈javascript图片预加载技术
2011-03-11 19:57:00