Reputation: 887
I am trying to importdata from a local CSV file into an Azure database. the idea is to allow the customer to do bulk inserts into the system using a preformatted CSV file.
The code I am using is:
BULK INSERT tmp_Import_Truck
FROM 'C:\ImportFrom\ImportData.csv'
WITH
(
FIELDTERMINATOR =',',
ROWTERMINATOR = '\n'
)
The problem is that I am getting an eror that it cannot open the file.
Msg 4861, Level 16, State 1, Line 1 Cannot bulk load because the file "C:\ImportFrom\ImportData.csv" could not be opened. Operating system error code (null).
How do I resolve this issue?
Upvotes: 3
Views: 2269
Reputation: 13460
You can't use bulk insert
in Azure SQL DB with file name, because it should be on the SQL Server machine.
You can use however BCP utility executed on your computer, to bulk copy this file to Azure SQL:
bcp database.dbo.table in C:\ImportFrom\ImportData.csv
-S yourserver.database.windows.net
-U someusername -P strongpassword
Upvotes: 3