Thursday, March 22, 2012

Export a table to excel sheet with data converting error

Hi,
I an using the following bcp utility to export a sql2000 table to an excel
sheet, there is only one filed data like this 00004563254666,
0000786653636....
The datatype is char(16), After I exported to excel it looks like this now
2.75E+11
Any ideas?
Thanks
select @.sql = 'bcp "' + @.dbName + ' select * from ##Testtable" queryout
"' + @.fullFileName + '" -c -CRAW'On Jul 26, 9:18 pm, "mecn" <mecn2...@.yahoo.com> wrote:
> Hi,
> I an using the following bcp utility to export a sql2000 table to an excel
> sheet, there is only one filed data like this 00004563254666,
> 0000786653636....
> The datatype is char(16), After I exported to excel it looks like this now
> 2.75E+11
> Any ideas?
> Thanks
> select @.sql = 'bcp "' + @.dbName + ' select * from ##Testtable" queryout
> "' + @.fullFileName + '" -c -CRAW'
Hi, you may try something like this:
select @.sql = 'bcp "' + @.dbName + ' select
convert(varchar(16),field) from ##Testtable" queryout
"' + @.fullFileName + '" -c -CRAW'

No comments:

Post a Comment