sqlserver建立远程查询
开始远程查询前:
----open:Ad Hoc Distributed Queries
EXEC sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
RECONFIGURE
结束查询:
-----close:Ad Hoc Distributed Queries
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure
示例:
SELECT gsjc ,
companyid ,
gscause
FROM OPENDATASOURCE('SQLOLEDB',
'Data Source=120.76.233.81,5433;User ID=lq;Password=lq123!@#').KMSLEY.dbo.basCompany