Please help me understand why the two variants of the bcp
command listed below fail at adding data to the DB.
The toy csv-file’s (it is in UTF-8 with BOM and has rn
at the end of each line including the last one) content is as follows:
1,"qwe"
2,"rty"
3,"uio"
4,"äöü"
The test table was created with the command
CREATE TABLE Import_data_test_1([column1][integer], [column2][nvarchar])
Firstly, I tried the bcp
command with the following switches:
bcp sn_test_2.dbo.Import_data_test_1 in D:UuuTest_1.csv -w -T -t , -r n
The result:
Starting copy...
SQLState = S1000, NativeError = 0
Error = [Microsoft][ODBC Driver 17 for SQL Server]Unexpected EOF encountered in BCP data-file
0 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total : 1
Also, I attempted to do it interactively like this:
bcp sn_test_2.dbo.Import_data_test_1 in D:UuuTest_1.csv -T
Enter the file storage type of field column1 [int-null]:
Enter prefix-length of field column1 [1]:
Enter field terminator [none]: ,
Enter the file storage type of field column2 [nvarchar]:
Enter prefix-length of field column2 [2]:
Enter field terminator [none]: (comment: I tried left it empty and enter n here, it did not make any difference)
Do you want to save this format information in a file? [Y/n] n
The result:
Starting copy...
0 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total : 1
I would appreciate explanation why it fails in both cases.