执行OPENROWSET(BULK)/ Azure SQL数据库时出错

时间:2017-10-26 16:25:26

标签: azure-sql-database openrowset

我使用“Active Directory - 集成”身份验证登录Azure SQL数据库,其中我仅提供公司域凭据;没有密码。

我尝试在客户端(笔记本电脑)上存储的.json文件上执行OPENROWSET:

Select BulkColumn
from OPENROWSET
(BULK 'C:\Users\username\Downloads\docs_by_day_IncludeDocs.json',
SINGLE_CLOB) as my_test

返回:

Msg 4861, Level 16, State 1, Line 12
Cannot bulk load because the file "C:\Users\username\Downloads
\docs_by_day_IncludeDocs.json" could not be opened.
Operating system error code (null).

此错误是否与尝试连接到本地客户端的Azure SQL数据库有关?与其他一些海报不同,错误消息没有明确标识Access问题。

我感谢任何帮助!

1 个答案:

答案 0 :(得分:2)

SQLAZURE不知道这条路径..

C:\Users\username\Downloads\docs_by_day_IncludeDocs.json

您必须将文档上传到存储帐户并尝试下面的内容

SELECT *
FROM OPENROWSET(BULK 'data/product.bcp', DATA_SOURCE = 'MyAzureBlobStorage',
 FORMATFILE='data/product.fmt', FORMATFILE_DATA_SOURCE = 'MyAzureBlobStorage') as data

在此之前,您需要创建一个存储帐户..

CREATE EXTERNAL DATA SOURCE MyAzureBlobStorage
 WITH ( TYPE = BLOB_STORAGE,
        LOCATION = 'https://myazureblobstorage.blob.core.windows.net',
        CREDENTIAL= MyAzureBlobStorageCredential);

<强>参考文献:
https://blogs.msdn.microsoft.com/sqlserverstorageengine/2017/02/23/loading-files-from-azure-blob-storage-into-azure-sql-database/