SQLSERVER跨库访问
select * from OPENDATASOURCE('SQLOLEDB','Data Source=IP;User ID=用户名;Password=密码').库名.dbo.表名
如果提示Ad Hoc Distributed Queries未启用的话,则执行以下语句:
use master
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
不需要使用的时候就关闭Ad Hoc Distributed Queries:
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure