SQL跨服查询
這時才想起跨庫查詢了。
1.開通分布式查詢權(quán)限
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
2.查詢
select a.ProjCode as '樓盤編號',b.projname as '樓盤名稱',count(1) as '房源量' from
?openrowset( 'SQLOLEDB ', 'IP地址(服務(wù)器名)'; '用戶名'; '密碼',[數(shù)據(jù)庫名].[dbo].[表名]) a
?, openrowset( 'SQLOLEDB ', 'IP地址(服務(wù)器名)'; '用戶名'; '密碼',[數(shù)據(jù)庫名].[dbo].[表名]) b
?where a.ProjCode=b.newcode GROUP by?? a.ProjCode ,b.projname order by? count(1) desc
?
3.然后換城市,只需要改IP、 庫名和表名了。
4.關(guān)閉
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure
轉(zhuǎn)載于:https://www.cnblogs.com/bobofsj11/archive/2010/05/06/1728794.html
總結(jié)
- 上一篇: 水星 MW316R V1 无线路由器管控
- 下一篇: SQL Server ldf 丢失的数据