跨Server查询

 

EXEC sp_configure 'show advanced options', 1 
 GO 
 RECONFIGURE 
 GO 
 EXEC sp_configure 'Ad Hoc Distributed Queries', 1 
 GO 
 RECONFIGURE 
 GO 
SELECT
    MAX(OldestCall)
FROM
(
    SELECT 
        FeildAA As FeildAAFROM  OPENDATASOURCE('SQLOLEDB','Data Source=1270.0.1;User ID=sa;Password=sa').DBNameA.dbo.TableNameA AS A
    INNER JOIN OPENDATASOURCE('SQLOLEDB','Data Source=127.0.0.1;User ID=sa;Password=sa').[DBNameB].[dbo].[CMS_TableNameB] AS B ON A.ID= B.ID
) AS AA

 

posted on 2015-11-24 14:38  chen110xi  阅读(179)  评论(0编辑  收藏  举报