Selecting data from two different servers in SQL Server

后端 未结 15 1722

How can I select data in the same query from two different databases that are on two different servers in SQL Server?

15条回答
  •  一生所求
    2020-11-22 08:00

    try this:

    SELECT * FROM OPENROWSET('SQLNCLI', 'Server=YOUR SERVER;Trusted_Connection=yes;','SELECT * FROM Table1') AS a
    UNION
    SELECT * FROM OPENROWSET('SQLNCLI', 'Server=ANOTHER SERVER;Trusted_Connection=yes;','SELECT * FROM Table1') AS a
    

提交回复
热议问题