我正在尝试创建一个将创建外部数据源的 SQL 存储过程。该位置是传递给过程的参数(例如,天蓝色存储帐户容器)。我无法接受 Location 变量(如下面的代码片段所示)。
DECLARE @Location varchar(max)
SET @Location = 'https://somestorageaccount.blob.core.windows.net/uploads'
PRINT @Location
--DROP EXTERNAL DATA SOURCE uploads
CREATE EXTERNAL DATA SOURCE uploads
WITH
(
TYPE = BLOB_STORAGE,
LOCATION = @Location,
CREDENTIAL = azurecred
);
错误消息是:
Msg 102, Level 15, State 1, Line 11
Incorrect syntax near '@Location'.
如果带有单引号的 url 替换了变量,它就可以工作。IE
CREATE EXTERNAL DATA SOURCE uploads
WITH
(
TYPE = BLOB_STORAGE,
LOCATION = 'https://somestorageaccount.blob.core.windows.net/uploads'
CREDENTIAL = azurecred
);
经过试验,我无法让它发挥作用。可能吗?