sql-server - 在 Azure SQL 中具有相同表名的数据库跨数据库查询

标签 sql-server database azure azure-sql-database

我有两个 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_NAMEOBJECT_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

参见下图中的示例:

enter image description here

引用: More Flexible Naming

谢谢。

关于sql-server - 在 Azure SQL 中具有相同表名的数据库跨数据库查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47849358/

相关文章:

visual-studio - 自 Visual Studio 2017 更新到版本 15.7.4 以来,AAD 身份验证不起作用

azure - Azure Web 应用程序中的 3 层 Web 应用程序

sql - 如何使用 Schemabound 创建包含来自 2 个不同数据库的表的索引 View

mysql - 使用 RMySQL、R 和 MySQL 连接到数据库

php - 尝试使用 PHP Parse.com 查询日期之间

mysql - 外键相关数据实现的理论解决方案

c# - 为什么我的 Azure 中托管的 ASP NET Web 服务没有执行任何操作?

sql-server - SQL Server 中 mysql "LIMIT "子句的等效语法是什么

SQL Server 2008 R2 : Find rows where column2 value present in column1

c# - Windows应用程序中的数据库连接