MSSQL开启远程开合库查询

select top 1 * from  OPENDATASOURCE(   
         'SQLOLEDB', 
         'Data Source=ip;User ID=*;Password=****' 
         ).数据库名.dbo.表名



#开启配置语句:

EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
EXEC sp_configure 'Ad Hoc Distributed Queries', 1
GO
RECONFIGURE
GO