I need Ur help regarding Join query between two different Azure SQL database with same table name and same structure. Actually I have two different database with same table name and whole fields with different data.
I would like to Transfer the data from One database to another on Azure Sql or Join the table (both the table have the same name and structure). For this I am using the "Elastic Database Query"
https://ppolyzos.com/2016/07/30/cross-database-queries-in-azure-sql-databases/
I am facing the error message while creating External Table “CREATE EXTERNAL TABLE [dbo].[Users]”
Error Message :- "There is already an object named 'Users' in the database."
Sample Database 1st
[Test].[dbo].[Users]
CREATE TABLE [Users] (
[UserGuid] uniqueidentifier NOT NULL
, [FirstName] nvarchar(90) NOT NULL
, [LastName] nvarchar(90) NOT NULL
, [UserID] nvarchar(50) NOT NULL
, [PasswordSalt] nvarchar(90) NOT NULL
, [Password] nvarchar(90) NOT NULL
, [PasswordChanged] datetime NULL
, [UserName] nvarchar(50) NOT NULL
);
GO
Database 2nd [TestAnother].[dbo].[Users]
CREATE TABLE [Users] (
[UserGuid] uniqueidentifier NOT NULL
, [FirstName] nvarchar(90) NOT NULL
, [LastName] nvarchar(90) NOT NULL
, [UserID] nvarchar(50) NOT NULL
, [PasswordSalt] nvarchar(90) NOT NULL
, [Password] nvarchar(90) NOT NULL
, [PasswordChanged] datetime NULL
, [UserName] nvarchar(50) NOT NULL
);
GO
I have written the Elastic Database Query as below :
Use TestAnother
Go
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'ABCmn!A4F43';
CREATE DATABASE SCOPED CREDENTIAL MyDbCredential
WITH IDENTITY = 'TestID',
SECRET = 'ABC9mn!A4F43';
CREATE EXTERNAL DATA SOURCE Connect2Test
WITH (
TYPE=RDBMS,
LOCATION='XXXX.database.windows.net',
DATABASE_NAME='Test',
CREDENTIAL= MyDbCredential,);
CREATE EXTERNAL TABLE [dbo].[Users] (
[UserGuid] uniqueidentifier NOT NULL
, [FirstName] nvarchar(90) NOT NULL
, [LastName] nvarchar(90) NOT NULL
, [UserID] nvarchar(50) NOT NULL
, [PasswordSalt] nvarchar(90) NOT NULL
, [Password] nvarchar(90) NOT NULL
, [PasswordChanged] datetime NULL
, [UserName] nvarchar(50) NOT NULL
)
WITH (
DATA_SOURCE = Connect2Test);
GO
If I remove or rename the Users table on "TestAnother" database then its work fine. But I wanna use the same Table name and structure.
How can I migrate the data from one table from One database to another table on other database and both the database table name and structure are same on Azure Sql environment.