Aasish
Aasish

Reputation: 377

Database having same table name cross database queries In Azure SQL

I have two azure SQL server each having single Database: Server1 with Database1 Server2 with Database2. Lets suppose Tables of two Database

Database1 has

Database2 has

I create external table Tbl_C of Database1 on Database2 and querying Tbl_C from Database2 works fine. Now I want to create external table Tbl_A of Database1 on Database2, how to create and query the cross database having same name? I am using SQL Server Express 2012. Please help me, thank you.

Upvotes: 2

Views: 1120

Answers (1)

sacse
sacse

Reputation: 3744

Please use SCHEMA_NAME and OBJECT_NAME in the create statement.

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

See the example in the image below:

enter image description here

Reference: More Flexible Naming

Thanks.

Upvotes: 3

Related Questions