SQL Server Bulk Import ROWTERMINATOR vbCrLf (\n) not working
sql, sql-server
Solution
For anybody landing here now, you can try using HEX codes
`ROWTERMINATOR = '0x0d0a'` or `ROWTERMINATOR = '0x0a'`
Problem
I know there are other threads on here regarding this problem and none of the recommended fixes are working. I have verified that the CRLF at the end of each record is a hex '0D0A'. I can do a replace in VBS on vbCrLf and it replaces every one of them. Here is a sample of my tab-delimited text file: ``` 01/16/2013 11:00 HS01 DocLast, DocFirst PA-C Occurred ML 11/20/2012 15:31 01/07/2013 09:40 HS01 DocLast, DocFirst PA-C Canceled ML 11/20/2012 15:36 Patient Canceled 20130103-57935 ``` I am executing this code against the text file in a stored procedure in SQL Server 2008: ``` set @sqlcmd = ' BULK INSERT #temp_import_records FROM ''' + @import_file + ''' WITH ( ROWTERMINATOR = ''\n'' )' ``` I am trying to insert this text into a temp table with 20 columns. This data only has 10 fields. With my code, both of these records are being installed into the same record in the temp table. I have tried setting the rowterminator to '0D0A' and '0x0A' and neither of them worked. What am I doing wrong?