In SQL Server vNext 1.1 we now have the ability to import a csv via the BULK INSERT command without having to specify the field or row terminator
You still need to specify the format, if you only do something like the following
You will be greeted with these errors
Msg 4832, Level 16, State 1, Line 10
Bulk load: An unexpected end of file was encountered in the data file.
Msg 7399, Level 16, State 1, Line 10
The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.
Msg 7330, Level 16, State 2, Line 10
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".
So let's take a look at how this all works
First create the following table
Now grab the csv file from here Songs played with Alexa.csv Either download the whole project and grab the file, or open in raw mode and copy and paste it into a file and save as Songs played with Alexa.csv
Now that you have the file and table ready, let's first take a look at how this was done before vNext 1.1
Here is what it looked like
As you can see, we specified a comma as the field terminator and a newline as the row terminator
You could also get it to work by just specifying the field terminator in this case
So what does the new syntax look like?
Here is the code that accomplished the same as above but by using the new WITH FORMAT = CSV option
I guess you could say it is a little cleaner, but all this really is is syntactic sugar
For Azure, it looks like this, I grabbed this straight from this Books On Line Page here
First you need to create a data source
And then you use that data source
For more examples including accessing data in a CSV file referencing a container in an Azure blob storage location go here https://msdn.microsoft.com/en-us/library/mt805207.aspx
That's all for today