启用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 * into OD_OP
FROM opendatasource( 'SQLOLEDB ', 'Data Source=192.168.0.99,1433;User ID=sa;Password=huixin ' ).TY2010.dbo.op