開始遠程查詢前:spa
----open:Ad Hoc Distributed Queries
EXEC sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
RECONFIGUREio
結束查詢:dva
-----close:Ad Hoc Distributed Queries查詢
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfiguredb
示例:word
SELECT gsjc ,
companyid ,
gscause
FROM OPENDATASOURCE('SQLOLEDB',
'Data Source=120.76.233.81,5433;User ID=lq;Password=lq123!@#').KMSLEY.dbo.basCompanyco