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 2008 Forums
 SSIS and Import/Export (2008)
 Truncation issue with flat file.

Author  Topic 

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2012-02-21 : 10:29:44
I have a stored proc executing in a SSIS package and its results are
going out to a flat file.

My first column is a memberNumber and a good example is

0034432

The problem is the 00's at the front are being truncated when everything is loaded into the excel file.

I have the column set up as a varchar. What else can i check to solve this?

Kind Regards

Rob

robvolk
Most Valuable Yak

15732 Posts

Posted - 2012-02-21 : 10:40:40
It's an Excel problem, there's nothing wrong with your file. Excel must have the column formatted as text BEFORE the data is imported. Opening the file directly with Excel won't work unless it initiates the Import wizard, and of course, setting the column to Text is the very last step.

The problem with adding an apostrophe (') before the leading zeros is that it becomes part of the data, which is not what you want. And if you do a find/replace it will convert it to a number unless you format the column as Text beforehand.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-02-21 : 10:50:30
instead of
0034432
you can export
="0034432"

Looks stupid but it works...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -