问题描述
我有一个需要去波兰的文件.在我的数据中,我有一个ó
.当我将数据输出到表时,ó
仍然存在,因为字段是NVARCHAR
.当我从表格剪切并粘贴到Excel或Notepad ++时,ó
保持不变
I have a file that needs to go to Poland. In my data I have an ó
. When I output the data to a table the ó
is still there as the field is NVARCHAR
. When I cut and paste from the table into Excel or Notepad++ the ó
stays
当我使用BCP实用程序导出数据时,如果我在Excel或Notepad ++中打开生成的文本文件,则ó
会更改为¢
.如果更改编码,有时字符会变成˘
.
When I use the BCP utility to export the data, the ó
is changed to a ¢
if I open the resulting text file in Excel or Notepad++. If I change the encoding sometimes the character becomes a ˘
.
我尝试了以下命令行开关,一次一次.-n
-N
-w
I have tried the following command line switches, one at a time.-n
-N
-w
推荐答案
您是否研究过-C
?
-C { ACP | OEM | RAW | code_page }
Specifies the code page of the data in the data file. code_page is
relevant only if the data contains char, varchar, or text columns
with character values greater than 127 or less than 32.
鉴于表的数据类型为Unicode(NVARCHAR),则还必须使用-c
(这可能会丢失一些Unicode字符)
Given your table's data type is Unicode (NVARCHAR), you also have to use -c
(which may lose some Unicode characters)
-c
Performs the operation using a character data type. This option
does not prompt for each field; it uses char as the storage type,
without prefixes and with \t (tab character) as the field
separator and \r\n (newline character) as the row terminator. -c
is not compatible with -w.
For more information, see [Use Character Format to Import or
Export Data (SQL Server)].
CREATE TABLE [dbo].[Test] (
[test] [nvarchar](100) NOT NULL
);
INSERT [dbo].[Test] ([test]) VALUES (N'helló wórld');
bcp dbo.Test out dbo.Test.dat -c -T -C ACP
只要Notepad ++可以检测到编码(UCS-2 Little Endian),不带-c
和-C ACP
的
-w
也应该起作用.我的简单示例使用Notepad ++ 6.7.7没问题.
-w
without -c
and -C ACP
should also work as long as Notepad++ can detect the encoding (UCS-2 Little Endian). I had no problem with my simple example using Notepad++ 6.7.7.
来源: https://msdn.microsoft.com/en-us/library/ms162802.aspx
这篇关于BCP和ó的字符编码问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!