Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to format the output to an excel file

Author  Topic 

itmasterw
Yak Posting Veteran

90 Posts

Posted - 2009-11-30 : 13:52:46
Hi
(1)I have a table that has one column where in one record it might look like this 00032 and in in another record it would look like this 01523 and in another like this 00002. I am using a Bulk copy comand to out put it to Excel but when it does it dropes all the leading zeros.
(2) I have a field that has 12 charicters but when it goes to excel it cuts it off given me the exponit notation.

I looked at the possibility of using a format file but I cannot see how ajust for these things in there.
Does any one have any ideas on what I can do here?
Thank you


ITM

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-11-30 : 13:56:40
It's a problem with Excel and not SQL Server. Just format that column to a string data type.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

itmasterw
Yak Posting Veteran

90 Posts

Posted - 2009-11-30 : 14:01:59
thanks for getting back to so fast, but is there away to format the excel file through Sql Server?


ITM
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-11-30 : 14:03:48
No, the change must be done inside Excel since it's just a display issue. The data is actually stored properly in the file already.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

itmasterw
Yak Posting Veteran

90 Posts

Posted - 2009-11-30 : 14:13:36
okay well thanks I appreaciate your help

ITM
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-11-30 : 14:28:08
You're welcome.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -