gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-10-30 22:07:16 24 4
gpt4 key购买 nike

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com