📌  相关文章
📜  如何从 2 个数据库中获取数据 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:33.404000             🧑  作者: Mango

代码示例1
-- Fetch data from the other database server
SELECT *
INTO #myTempTable
FROM OPENQUERY([DB2], 'SELECT * FROM [MyDatabaseOnDB2].[dbo].[MyOtherTable]')

-- Now I can join my temp table to see the data
SELECT * FROM [MyDatabaseOnDB1].[dbo].[MyTable] tab1
    INNER JOIN #myTempTable tab2 ON tab1.ID = tab2.ID