I'm trying to bulk insert data from a csv stored in a blob storage account in an Azure SQL database using a format file.
Here is what I am attempting to run:
BULK INSERT dbo.MyTable
FROM 'MyCSV.csv'
WITH(DATA_SOURCE = 'MyBlobStorageAccount'
, FIRSTROW = 2
, CODEPAGE = '65001'
, FORMATFILE = 'MyFormatFile.xml'
);
I get the following error:
Cannot bulk load because the file "MyFormatFile.xml" could not be opened. Operating system error code (null).
Now, I can successfully load other files from the same storage account that do not use a format file and I can successfully load the contents of MyFormatFile.xml using the following, so its not a permissions / credentials issue:
IF(OBJECT_ID('tempdb..#data') IS NOT NULL)
DROP TABLE #data
CREATE TABLE #data
(
data VARCHAR (MAX)
)
BULK INSERT #data
FROM 'MyFormatFile.xml'
WITH (DATA_SOURCE = 'MyBlobStorageAccount',
FIRSTROW = 1)
What am I doing wrong here? The Microsoft Documentation says that this is supported: Bulk Insert
