Question:
I seem to be unable to run a bulk insert on a SQL table from a CSV file that gets sent through FTP to our server. It runs without error, but alters 0 rows.If I copy the data into another file, it works, but I need to be able to do this automatically without messing with the file myself. Opening them both, the only differences I can see are that the line breaks are CRLF on the new file, and just LF on the original. Encoding looks to be the same as well on both, so I must be missing something not in the other similar questions asked.
Sample script below:
Answer:
You need to use ROWTERMINATOR=’0x0a’Your code will become:
At paragraph “Specifying \n as a Row Terminator for Bulk Import”
Reporting here what is important for the question:
When you specify \n as a row terminator for bulk import, or implicitly use the default row terminator, bcp and the BULK INSERT statement expect a carriage return-line feed combination (CRLF) as the row terminator. If your source file uses a line feed character only (LF) as the row terminator – as is typical in files generated on Unix and Linux computers – use hexadecimal notation to specify the LF row terminator. For example, in a BULK INSERT statement
If you have better answer, please add a comment about this, thank you!