I always use BULK
.
However, as the server of Azure obviously located in somewhere else other than your pc, you need to modify it a bit:
CREATE EXTERNAL DATA SOURCE MyAzureBlobStorage
WITH ( TYPE = BLOB_STORAGE,
LOCATION = 'https://xxxxxxxx.blob.core.windows.net/miladcontainer'
);
The above code first creates a virtual DATA SOURCE
, and then you can use BULK INSERT
to upload from it with the following code:
BULK INSERT clinical_survey
FROM 'clinical_survey.csv'
WITH (DATA_SOURCE = 'MyAzureBlobStorage',
FORMAT = 'CSV');
Steps should be taken before executing the code is as follows:
1- Create a blob storage container (search at Azure and create a public one)
2- When asked, choose BLOB PUBLIC STORAGE
3- Upload your CSV file in Blob that was just created
4- Execute the above codes separately