(
         'SQLOLEDB',
         
'Data Source=127.0.0.1;User ID=sa;Password=sa'
         ).testdata.dbo.eh_jobsafeguard
where 1=1


--开启Ad Hoc Distributed Queries:
--
EXEC sp_configure 'show advanced options', 1 
--
GO 
--
RECONFIGURE 
--
GO 
--
EXEC sp_configure 'Ad Hoc Distributed Queries', 1 
--
GO 
--
RECONFIGURE 
--
GO


--关闭Ad Hoc Distributed Queries:
--
exec sp_configure 'Ad Hoc Distributed Queries',0
--
reconfigure
--
exec sp_configure 'show advanced options',0
--
注意,必须在允许OLEDB连接的情况下,此方法才可行

相关文章: