“Column is too long” error with BULK INSERT

前端 未结 4 1168
不思量自难忘°
不思量自难忘° 2020-12-16 10:48

I am trying to run the following command to bulk insert data from a CSV file--

 BULK INSERT TestDB.dbo.patent
 FROM \'C:\\1patents.csv\'
 WITH (FIRSTROW = 1,         


        
相关标签:
4条回答
  • 2020-12-16 11:12

    Like answered above, I had the same problem importing a csv file into SQL Server. I was using ROWTERMINATOR = '\n' and I also tried to use '\r\n' and '\r'. None of them worked.

    But when using ROWTERMINATOR = '0x0a' the table loaded without problems.

    I don't know the "why?" behind this, hopefully somebody else can shed light over it.

    0 讨论(0)
  • 2020-12-16 11:21

    I got extraction from Oracle/Unix. I replaced \r\n by ROWTERMINATOR = '0x0a' and it worked for me.
    Thanks a lot !

    0 讨论(0)
  • 2020-12-16 11:25

    Unless the file source is Unix, chances are the file's row terminator is really

    \r\n

    Either use a hex editor to validate the file's terminator, or just try that as the row terminator.

    0 讨论(0)
  • 2020-12-16 11:25

    I faced the similar problem and came to know that unless the file is UNIX type \r\n is fine .

    When you generate the format file (.fmt or .xml), notice the 3rd column from left. its called min length of column. At times sql server defaults it to 2 though you don't mention it in create script. Change that value to 0 . Sometimes you might have to allow NULL also ,so change that to zero and it should work now

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