RE: bcp to export sql table to excel, how avoid suppress of leading ze

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi Pensio,

This is Mark, a SQL Server Engineer. I'm glas to assist you with the issue.

Based on the requirement, please try the following action
1 Please set the column ArticleNumber as TEXT data type in SQL Server.

2 Creating a non-XML format file for Unicode native data.
There is an article to share with
you:http://msdn.microsoft.com/en-us/library/ms191516.aspx

bcp dataBaseX.dbo.FileToExport nul -T -N -f c:\bcp.fmt

3 run the command
declare @sql varchar(500)
select @sql = 'bcp dataBaseX.dbo.FileToExport out c:\Excel***.xls -f
c:\bcp.fmt -T'
exec master..xp_cmdshell @sql

Then the leading zeros will be seen in the excel ***.

Besides, since the bcp is used to export data out of tables into data
files and the column name is not considered as data, the column name() will
not be copied from SQL Server into data file.

Best regards,
Mark Han
Microsoft Online Community Support
===========================================================
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: msdnmg@xxxxxxxxxxxxxx
===========================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for
non-urgent issues where an initial response from the community
or a Microsoft Support Engineer within 1 business day is acceptable.
Please note that each follow up response may take approximately
2 business days as the support professional working with you may
need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by
contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
============================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
=========================================================

.


Quantcast