使用UTF-8数据的格式文件进行SQL Server批量导入 [英] SQL Server Bulk Import With Format File of UTF-8 Data

查看:865
本文介绍了使用UTF-8数据的格式文件进行SQL Server批量导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直指的是以下页面:

I have been referring to the following page:

http://msdn.microsoft.com/en-us/library/ms178129.aspx

我只是想批量导入具有Unicode字符的文件中的一些数据。我试过用UC-2,UTF-8等编码实际数据文件,但没有任何作用。我还修改了格式文件以使用 SQLNCHAR ,但它仍然不起作用并给出错误:

I simply want to bulk import some data from a file that has Unicode characters. I have tried encoding the actual data file in UC-2, UTF-8, etc but nothing works. I have also modified the format file to use SQLNCHAR, but still it doesn't work and gives error:


第1行第1列的批量加载数据转换错误(截断)

Bulk load data conversion error (truncation) for row 1, column 1

我认为它必须做使用以上链接中的此声明:

I think it has to do with this statement from the above link:


对于使用Unicode字符数据文件的格式文件,所有
输入字段必须是Unicode文本字符串(即固定大小的
或字符终止的Unicode字符串)。

这究竟是什么意思?我认为这意味着每个字符串需要一个固定的2个字节,在UCS-2中编码文件应该处理???

What exactly does this mean? I thought this means every character string needs to be a fixed 2 bytes, which encoding the file in UCS-2 should handle???

推荐答案

这篇博客文章非常有帮助并解决了我的问题:

This blog post was really helpful and solved my problem:

http://blogs.msdn.com/b/joaol/archive/2008/11/27/bulk-insert-using-unicode -data-files.aspx

需要注意的其他事项 - Java类正在生成数据文件。为了使上述解决方案起作用,数据文件需要以 UTF-16LE 进行编码,可以在OutputStreamWriter的构造函数中设置(例如)。

Something else to note - a Java class was generating the data file. In order for the above solution to work, the data file needed to be encoded in UTF-16LE, which can be set in the constructor of OutputStreamWriter (for example).

这篇关于使用UTF-8数据的格式文件进行SQL Server批量导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆