简体   繁体   English

SQL Server 2008 R2 BCP命令将nvarchar数据导出到Excel

[英]SQL server 2008 R2 BCP command export nvarchar data to excel

I m using SQL Server 2008 R2 BCP command to export data from query to excel. 我正在使用SQL Server 2008 R2 BCP命令将数据从查询导出到Excel。

Now the problem is, while exporting to excel one of the column (CustomerName) is coming "????" 现在的问题是,导出到excel时,其中一列(CustomerName)出现了“ ????” .. i checkout the difference between other columns which are having exact value as in database table. ..我签出具有与数据库表中相同的确切值的其他列之间的差异。 The difference is datatype VARCHAR & NVARCHAR. 区别在于数据类型为VARCHAR和NVARCHAR。 Now i tried various options or switches provided by BCP command but still was not able to export the names correctly. 现在,我尝试了BCP命令提供的各种选项或开关,但仍然无法正确导出名称。

One of live example is "合肥公交集团" this is the original value in my database table & when extracting to excel i get "???????" 实时示例之一是“合肥公交集团”,这是我的数据库表中的原始值,当提取到excel时,我得到“ ???????” some question marks. 一些问号。

I have used -N, -n, -w but failed to get desired result. 我使用了-N,-n,-w,但是没有得到想要的结果。

I also tried code_page but failed (maybe my syntax was wrong). 我也尝试了code_page但失败了(也许我的语法是错误的)。

Please help.... 请帮忙....

Regards, Avi 问候,阿维

Eric tried this BCP command - c:\\Avi>bcp "SELECT * from CMRQATEST..test" queryout "D:\\Testing\\nvarchartexttest\\test.xls" -C 936 -S localhost -T -c 埃里克(Eric)尝试了此BCP命令-c:\\ Avi> bcp“ SELECT * from CMRQATEST..test” queryout“ D:\\ Testing \\ nvarchartexttest \\ test.xls” -C 936 -S localhost -T -c

Result: 结果:

在此处输入图片说明

When Copying from SSMS, and pasting in excel sheet : 从SSMS复制并粘贴到Excel工作表时: 在此处输入图片说明

在此处输入图片说明

请尝试在您的BCP命令中添加-C 936 ,这是简体中文的代码(Windows ANSI 936)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM