utf-8 文本文件的 bcp 文件结尾错误

发布于 2025-01-16 05:16:39 字数 1460 浏览 4 评论 0原文

我们当前的设置使用 bcp 将 .txt 文件 (UTF-16) 加载到 sql server (2012) 中。

我们已将这些文件的编码从 UTF-16 更改为 UTF-8。这节省了我们的处理时间(从源系统导出时)。

然而,随着这一变化。我们现在遇到文件结束错误。

错误 = [microsoft][sql server 本机客户端 10.0]bcp 数据文件中遇到意外的 eof

在此处输入图像描述

这是我们的 bcp 错误文件中的内容。

#@ 第 2 行,第 1 列:BCP 数据文件中遇到意外的 EOF @#

这是我们拥有的最小文件之一。它包含提取时间。

输入图片此处描述

我尝试过以下 bcp 命令:

[server].master.dbo.xp_cmdshell 'bcp "aida_ods_nl_prd.imp.t_aidaextracttime" in c:\temp\aidaextracttime.txt -fc:\temp\bcp_format_files\aidaextracttime.fmt -q -c raw -w -f2 -r\n -t -s [server]\sql2012 -ec:\temp\bcp_errors\aidaextracttime_errors.txt'

Does bcp support utf-8 in sql 2012? 如果是, 我做错了什么?行终止符-r/n是否不正确>

        @bcp_parms
    ==========
    -q     - set quoted_identifiers on
    -C RAW - codepage - no conversion from one codepage to another
    -w     - performs the bulk copy operation using Unicode characters
    -F1    - First row is the 1st row (no column headers)
    -F2    - First row is the 2nd row (row 1 has column headers)
    -r\r   - row terminator (override default with a carriage return)
    -T     - connect to SQL Server with a trusted connection

Our current setup uses bcp to load .txt files (UTF-16) into sql server (2012).

We have changed the encoding of these files from UTF-16 to UTF-8. This saves our processing times (when exporting from the source system).

However, upon this change. We now encounter an end of file error.

error = [microsoft][sql server native client 10.0]unexpected eof encountered in bcp data-file

enter image description here

This is what is in our bcp error file.

#@ Row 2, Column 1: Unexpected EOF encountered in BCP data-file @#

This is one of the smallest files we have. It contains the Extract time.

enter image description here

I have tried the following bcp command:

[server].master.dbo.xp_cmdshell 'bcp "aida_ods_nl_prd.imp.t_aidaextracttime" in c:\temp\aidaextracttime.txt -fc:\temp\bcp_format_files\aidaextracttime.fmt -q -c raw -w -f2 -r\n -t -s [server]\sql2012 -ec:\temp\bcp_errors\aidaextracttime_errors.txt'

Does bcp support utf-8 in sql 2012?
If yes,
What am I doing wrong? Is the row terminator -r/n not correct>

        @bcp_parms
    ==========
    -q     - set quoted_identifiers on
    -C RAW - codepage - no conversion from one codepage to another
    -w     - performs the bulk copy operation using Unicode characters
    -F1    - First row is the 1st row (no column headers)
    -F2    - First row is the 2nd row (row 1 has column headers)
    -r\r   - row terminator (override default with a carriage return)
    -T     - connect to SQL Server with a trusted connection

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文