简体   繁体   中英

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.

Now the problem is, while exporting to excel one of the column (CustomerName) is coming "????" .. i checkout the difference between other columns which are having exact value as in database table. The difference is datatype VARCHAR & NVARCHAR. Now i tried various options or switches provided by BCP command but still was not able to export the names correctly.

One of live example is "合肥公交集团" this is the original value in my database table & when extracting to excel i get "???????" some question marks.

I have used -N, -n, -w but failed to get desired result.

I also tried code_page but failed (maybe my syntax was wrong).

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

Result:

在此处输入图片说明

When Copying from SSMS, and pasting in excel sheet : 在此处输入图片说明

在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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