我正在尝试将数据从一个数据库表插入到Azure SQL中的另一个数据库表(在同一服务器上)。我看到以下内容:
https://azure.microsoft.com/en-us/blog/querying-remote-databases-in-azure-sql-db/
这描述了我应该能够做到以下几点:
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
);
但是当我运行时,我得到以下内容:
找不到指定的凭证。
如何为此目的创建凭据?有没有更好的方法来解决这个问题?
答案 0 :(得分:6)
这就是我最终的结果:
-- 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
具有挑战性的一点是: