Bulk insert rowterminator issue

前端 未结 2 2002
误落风尘
误落风尘 2021-01-04 14:15

I have this csv named test.csv with the content below

1,\"test user\",,,4075619900,example@example.com,\"Aldelo for Restaurants\",\"this is my deal\",,\"loca         


        
相关标签:
2条回答
  • 2021-01-04 14:55

    I think problem is that your csv file uses \n as EOL (unix way). BULK INSERT in SQL Server is "smart" and even if you specify ROWTERMINATOR as \n, which in theory should resolve your problem, it prepends it with \r so you end up with \r\n as row terminator.

    Try using ROWTERMINATOR='0x0A'. In this case SQL Server doesn't perform any magic tricks and just uses the value you've set as row terminator.
    Works for me. :)

    0 讨论(0)
  • 2021-01-04 14:59

    CHAR(124) is | and CHAR(10) is \n

    You probably need CHAR(13) and CHAR(10) as Row Terminator

    http://www.techonthenet.com/ascii/chart.php

    0 讨论(0)
提交回复
热议问题