sqlserver跨库查询
show advanced options 选项用来显示 sp_configure 系统存储过程高级选项。当 show advanced options 设置为 1 时,可以使用 sp_configure 列出高级选项。默认值为 0。
该设置将立即生效,无需重新启动服务器。
===============================================
exec sp_configure 'show advanced options',0 reconfigure exec sp_configure 'Ad Hoc Distributed Queries',0 reconfigure --开启是1,关闭是0 exec sp_configure 'show advanced options',1 reconfigure exec sp_configure 'Ad Hoc Distributed Queries',1 reconfigure
===============================================
select * from openrowset( 'SQLOLEDB ', 'sql服务器名'; '用户名'; '密码',数据库名.dbo.表名)
----正确查询---- select top 300 * from openrowset( 'SQLOLEDB ', '111.33.400.55,37628'; 'TMUser'; 'Kigt75*#666666',BMIS.dbo.Goods)
select * from openrowset( 'SQLOLEDB' , '111.33.55.66,37629' ; 'TestShopUser' ; 'T123Test123123..' , [Test-ShopV2].dbo.[Trade]) order by ConfirmDate asc
select top 10 * from openrowset( 'SQLOLEDB' , '111.22.333.44,37629' ; 'ShopUser' ; 'NKigt..75*#Fbve$mshopp' , [ShopV2].dbo.[Users]) where SubAcc='2847763955'
===============================================