Bulk Insert Failed “Bulk load data conversion error (truncation)”

£可爱£侵袭症+ 提交于 2019-12-06 08:54:30

The problem is likely the row terminator is not working due to the file format.

Try:

ROWTERMINATOR = '0x0a'

EDIT

Actually I just notice you are using forward slash, it should be backslash, so this may work:

ROWTERMINATOR = '\n'

From SQL Server Management Studio (SSMS), for a Unix-style file, ROWTERMINATOR = '0x0a' works. However, ROWTERMINATOR = '\n' does not since SSMS apparently interprets the \n as a Windows-style end of line sequence (\r\n) and fixes/breaks it for you.

Interestingly, if you send the same ROWTERMINATOR = '\n' from Java code through the SQL Server JDBC driver, it will be seen as the Unix-style end-of-line since nothing in the middle throws in the extra \r.

So, you have to do two things:

1 - Make sure you understand how your data file actually does end-of-line.

2 - Make sure you understand how your means of delivering the BULK INSERT sql to SQL Server is interpreting any escape sequences. My limited experience is that using hex ('0x0a') for SQL Server SQL works in all environments.

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