I'm having a lot of issues importing data to SQL Azure using the bcp utility. They issues seem to mainly center around dates, so I have distilled this issue down to the following:
data (cp1252 encoding) -
2015-09-01 00:00:00 2015-09-01 00:00:00 2015-09-01 00:00:00 2015-09-01 00:00:00
fmt -
11.0 1 1 SQLDATETIME 0 8 "," 1 Date ""
schema -
CREATE TABLE test_table ( Date DATETIME NOT NULL );
bcp command line -
bcp test_table in stest.csv -S tcp:<our_server> -d <our_db> -U <our_user> -P <super_secret_password> -k -r "\r\n" -f test.fmt -e test_errors.txt
error output:
#@ Row 1, Column 1: Invalid time format @# 20420-02-27 702:31:15.350
As you can see, the data reported by the error bears no relation to the actual data we're passing in.
I've tried varying date formats with different results, none of them good or useful in any way, all of them reporting data in the errors file that looks nothing like the data we're trying to import. I've tried putting the csv file in utf-8 and, cp1252, but nothing changes. It does appear to be reading the proper file though, as changing the date to something different will result in a different seemingly made up error:
data -
2009-10-11 00:00:00
error -
#@ Row 1, Column 1: Invalid time format @# 7370-07-22 701:58:30.123
I've also tried various different command line switches, -R produced:
Starting copy... SQLState = 37000, NativeError = 102 Error = [Microsoft][SQL Server Native Client 11.0][SQL Server]Incorrect syntax near ','. 0 rows copied. Network packet size (bytes): 4096 Clock Time (ms.) Total : 47...despite the fact that there is no , in the test.csv, or the command line.