“Column is too long” error with BULK INSERT

▼魔方 西西 提交于 2019-11-30 17:09:13
Fabien Cousin

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

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.

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!