---启用Ad Hoc Distributed Queries
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
---执行远程访问数据库语句
select * from OPENDATASOURCE('SQLOLEDB','data source=.;user id=sa;password=7788250').Fuyoo_SpotTransactionsWebCq.dbo.Auction ---使用完成后,关闭Ad Hoc Distributed Queries
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure 为什么上面的不能一起执行,一起执行还是会出现 " 消息 15281,级别 16,状态 1,第 7 行
SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的 STATEMENT'OpenRowset/OpenDatasource' 的访问,因为此组件已......" 按顺序分三步执行才行..。 如果放到事务里是不是就可以了呢,应该怎么写?事务sql serverOPENDATASOURCE
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
---执行远程访问数据库语句
select * from OPENDATASOURCE('SQLOLEDB','data source=.;user id=sa;password=7788250').Fuyoo_SpotTransactionsWebCq.dbo.Auction ---使用完成后,关闭Ad Hoc Distributed Queries
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure 为什么上面的不能一起执行,一起执行还是会出现 " 消息 15281,级别 16,状态 1,第 7 行
SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的 STATEMENT'OpenRowset/OpenDatasource' 的访问,因为此组件已......" 按顺序分三步执行才行..。 如果放到事务里是不是就可以了呢,应该怎么写?事务sql serverOPENDATASOURCE
我一开始也执行报错,加了一个go,改成这样后,我试了试,就不报错了:
--第一次的语句
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
go --加了一个go
---第二次的语句,执行远程访问数据库语句
select *
from OPENDATASOURCE('SQLOLEDB','data source=192.168.1.108;user id=sa;password=yupeigu').ggg.dbo.tb ---第三次语句,使用完成后,关闭Ad Hoc Distributed Queries
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure
我一开始也执行报错,加了一个go,改成这样后,我试了试,就不报错了:
--第一次的语句
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
go --加了一个go
---第二次的语句,执行远程访问数据库语句
select *
from OPENDATASOURCE('SQLOLEDB','data source=192.168.1.108;user id=sa;password=yupeigu').ggg.dbo.tb ---第三次语句,使用完成后,关闭Ad Hoc Distributed Queries
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure
果然,, 谢谢大虾