【问题标题】:bcp output from SQL Server replaces € symbol with an underscoreSQL Server 的 bcp 输出将 € 符号替换为下划线
【发布时间】:2015-09-27 13:29:09
【问题描述】:

嗨,也许有人可以帮我解释一下,使用 sql 查询我得到供应商发票详细信息的列表,然后使用 bcp 输出到 csv 文件以导入 ERP 系统,该查询的结果在那里是一些包含€ 符号的供应商代码,但在创建 csv 文件时,€ 符号被替换为 _

€ 符号在 SQL Server 中显示正常,但在下面的 csv 文件中没有是我的输出命令

set @bcpCommand = 'bcp "select Supplier_Code,DocType,Invoice_No,Description,Net_Total,Vat_Total,Total from [MyDatabase].[dbo].tempPurchInv order by Invoice_No asc" queryout  '+@filename+ '.csv' +' '+ '-c -t, -T -S' +' '+ @@SERVERNAME

exec master..xp_cmdshell @bcpCommand

【问题讨论】:

  • @marc_s,我相信 -N 也会以本机(二进制)导出非字符列,因此文件格式不会是逗号分隔的文本文件。

标签: sql sql-server csv bcp


【解决方案1】:

如果您不指定代码页,OEM 代码页将用于 char/varchar 列。尝试将-C RAW 添加到 BCP 命令或支持€ 符号的代码页:

SET @bcpCommand = 'bcp "select Supplier_Code,DocType,Invoice_No,Description,Net_Total,Vat_Total,Total from [MyDatabase].[dbo].tempPurchInv order by Invoice_No asc" queryout  '+@filename+ '.csv' +' '+ '-c -t, -T -C RAW -S' +' '+ @@SERVERNAME;

EXEC master..xp_cmdshell @bcpCommand;

编辑:

请注意,消费系统需要知道非 Unicode 文件的代码页。使用RAW 规范,这将是列排序规则的代码页。

【讨论】:

  • 感谢您的帮助,效果很好,解释很好。
猜你喜欢
  • 1970-01-01
  • 2021-01-11
  • 2010-11-19
  • 1970-01-01
  • 2019-02-08
  • 1970-01-01
  • 1970-01-01
  • 2016-12-19
  • 1970-01-01
相关资源
最近更新 更多