Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
927 views
in Technique[技术] by (71.8m points)

error executing OPENROWSET (BULK) / Azure SQL Database

I am logged into an Azure SQL Database, using "Active Directory - Integrated" authentication wherein I supply my company domain credentials only; no password.

I tried executing OPENROWSET on a .json file stored on my client (laptop):

Select BulkColumn
from OPENROWSET
(BULK 'C:UsersusernameDownloadsdocs_by_day_IncludeDocs.json',
SINGLE_CLOB) as my_test

which returned:

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

Does this error have something to do with Azure SQL Database trying to connect to my local client? Unlike some other posters, the error message does not explicitly identify an Access problem.

I appreciate any assistance!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

SQLAZURE has no idea of this path..

C:UsersusernameDownloadsdocs_by_day_IncludeDocs.json

you will have to upload the doc to a storage account and try some thing like below

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

Prior to that, you will need to create a storage account..

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

References:
https://blogs.msdn.microsoft.com/sqlserverstorageengine/2017/02/23/loading-files-from-azure-blob-storage-into-azure-sql-database/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...