This is the BCP command I use for inserting data in SQL server:
bcp sfnav.dbo.Customer in "C:\Users\TSL\Desktop\TSL Data\ID_Customer_151124.csv" -F2 -c -t "^" -r "\n" -S ftpserver\sqlexpress -U abc -P xyz
When I try to run the same command in a batch file it results in an error:
call bcp sfnav.dbo.Customer in "C:\Users\TSL\Desktop\TSL Data\ID_Customer_151124.csv" -F2 -c -t "^" -r "\n" -S ftpserver\sqlexpress -U abc -P xyz
Error:
Starting copy... SQLState = 22001, NativeError = 0 Error = [Microsoft][ODBC Driver 11 for SQL Server]String data, right truncation SQLState = 22001, NativeError = 0
\r\n
. Check your data file in a viewer that shows special characters. Eg in Notepad++, go to View>Show Symbol>Show All Characters and inspect the row delimiter. – TT. Feb 17 '16 at 9:50\n
, try the hexadecimal value:-r "0x0a"
– TT. Feb 17 '16 at 9:57-r \r\n
instead of-r \n
. – TT. Feb 17 '16 at 11:01