-- 开启远程选项
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure


-- 方法1:
SELECT top 5 * FROM OPENDATASOURCE('SQLOLEDB','Data Source=192.168.2.208;User ID=sa;Password=ccpg@2015').[CCPG_PM].dbo.[COM_UserInfo] P where p.[GC_Flag]=0

-- 方法2:
SELECT top 5 * FROM OPENROWSET('SQLNCLI','192.168.2.208';'sa';'ccpg@2015','select * from [CCPG_PM].dbo.[COM_UserInfo] P where p.[GC_Flag]=0') AS a


-- 关闭远程选项
exec sp_configure 'Ad Hoc Distributed Queries',0 
reconfigure 
exec sp_configure 'show advanced options',0 
reconfigure

 

相关文章:

  • 2021-10-25
  • 2022-02-10
  • 2021-12-09
  • 2021-11-16
  • 2021-08-24
  • 2021-05-10
  • 2021-09-15
  • 2022-02-28
猜你喜欢
  • 2021-12-21
  • 2021-09-04
  • 2021-09-27
  • 2021-07-14
相关资源
相似解决方案