I'm trying to insert data from one database table into another database table (on the same server) in Azure SQL. I see the following:
https://azure.microsoft.com/en-us/blog/querying-remote-databases-in-azure-sql-db/
This describes that I should be able to do the following:
CREATE EXTERNAL DATA SOURCE RemoteReferenceData
WITH
(
TYPE=RDBMS,
LOCATION='myserver.database.windows.net',
DATABASE_NAME='_2016-09-07-17412',
CREDENTIAL= SqlUser
);
CREATE EXTERNAL TABLE [dbo].[RemotePhotos](
[PhotoId] int NOT NULL,
[Url] nvarchar(max) NULL,
)
WITH
(
DATA_SOURCE = RemoteReferenceData
);
However I get the following when I run this:
The specified credential cannot be found.
How can I go about creating a credential for this purpose? Is there a better way to go about this?
This is what I ended up with:
-- Cleanup
DROP EXTERNAL TABLE OldPhoto
DROP EXTERNAL DATA SOURCE RemoteReferenceData
DROP DATABASE SCOPED CREDENTIAL credentialName
DROP MASTER KEY
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'password';
CREATE DATABASE SCOPED CREDENTIAL credentialName
WITH IDENTITY = 'credentialName',
SECRET = 'password';
CREATE EXTERNAL DATA SOURCE RemoteReferenceData
WITH
(
TYPE=RDBMS,
LOCATION='myserver.database.windows.net',
DATABASE_NAME='mydb',
CREDENTIAL= credentialName
);
CREATE EXTERNAL TABLE dbo.OldPhoto(
[PhotoId] [int] NOT NULL,
[Url] [nvarchar](300) NULL
)
WITH
(
DATA_SOURCE = RemoteReferenceData
);
Select top 20 * from dbo.OldPhoto
The challenging bits were:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With