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

 

posted @ 2019-04-12 18:28  EFLand  阅读(659)  评论(0编辑  收藏  举报