Bulk insert, SQL Server 2000, unix linebreaks

后端 未结 8 936
旧时难觅i
旧时难觅i 2020-12-13 13:05

I am trying to insert a .csv file into a database with unix linebreaks. The command I am running is:

BULK INSERT table_name
FROM \'C:\\file.csv\' 
WITH 
( 
         


        
8条回答
  •  执笔经年
    2020-12-13 13:47

    I felt compelled to contribute as I was having the same issue, and I need to read 2 UNIX files from SAP at least a couple of times a day. Therefore, instead of using unix2dos, I needed something with less manual intervention and more automatic via programming.

    As noted, the Char(10) works within the sql string. I didn't want to use an sql string, and so I used ''''+Char(10)+'''', but for some reason, this didn't compile.

    What did work very slick was: with (ROWTERMINATOR = '0x0a')

    Problem solved with Hex!

    Hope this helps someone.

提交回复
热议问题