我有两个 azure 的 SQL 服务器,每个服务器都有一个数据库: 服务器 1 和数据库 1 服务器 2 和数据库 2。 让我们假设两个数据库的表
数据库1有
- Tbl_A
- Tbl_B
- Tbl_C
数据库2有
- Tbl_A
- Tbl_B
我在 Database2 上创建 Database1 的外部表 Tbl_C 并从 Database2 查询 Tbl_C 工作正常。现在我想在Database2上创建Database1的外部表Tbl_A,如何创建和查询同名的跨数据库?我正在使用 SQL Server Express 2012。请帮助我,谢谢。
最佳答案
请在创建语句中使用SCHEMA_NAME
和OBJECT_NAME
。
Several important scenarios require the ability to name your external table differently than the original table on the remote database. Any scenario where a local table already exists with the same name as your remote table are examples of that. All of these scenarios require the ability to use an alias for the remote table name
参见下图中的示例:
谢谢。
关于sql-server - 在 Azure SQL 中具有相同表名的数据库跨数据库查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47849358/