dbTalk Databases Forums  

need leading zeros when export to text file

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss need leading zeros when export to text file in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jess
 
Posts: n/a

Default need leading zeros when export to text file - 12-12-2004 , 10:19 PM






I used to DTS to export data from DB2 to text file with delimited characters
instead of fixed width format.
In the text file, I notice that the numeric fields were not padded with
leading zeros, but I need the leading zeroes.

I tried another method by importing from DB2 to a SQL table and when I run
query on the table, it doesn't show leading zeroes as well.( In DB2, the data
are with leading zeroes)

Has anyone got any idea on the above ? thnks.


Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: need leading zeros when export to text file - 12-13-2004 , 12:49 AM






In message <254C5E54-6104-4060-9938-1008D5FA3C1D (AT) microsoft (DOT) com>, Jess
<Jess (AT) discussions (DOT) microsoft.com> writes
Quote:
I used to DTS to export data from DB2 to text file with delimited characters
instead of fixed width format.
In the text file, I notice that the numeric fields were not padded with
leading zeros, but I need the leading zeroes.

I tried another method by importing from DB2 to a SQL table and when I run
query on the table, it doesn't show leading zeroes as well.( In DB2, the data
are with leading zeroes)

Has anyone got any idea on the above ? thnks.

In DB2 I assume you could write a query that fomatted the data first, or
it is definitely possible in T-SQL, e.g.

SELETCT RIGHT('0000000000' + CAST(NumericCol AS varchar(10), 10) AS
NumericCol) FROM Table

Or

you could do this formatting in an ActiveX Script Transform, using some
VBScript, e.g.

DTSDestinatination(1).Value = Right("0000000000" +
CStr(DTSSource(1).Value), 10)

--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



Reply With Quote
  #3  
Old   
Jess
 
Posts: n/a

Default Re: need leading zeros when export to text file - 12-13-2004 , 03:17 AM



Thanks Darren for the solution.
I tried in the ActiveX Script Transform, using some
VBScript .It worked fine..


"Darren Green" wrote:

Quote:
In message <254C5E54-6104-4060-9938-1008D5FA3C1D (AT) microsoft (DOT) com>, Jess
Jess (AT) discussions (DOT) microsoft.com> writes
I used to DTS to export data from DB2 to text file with delimited characters
instead of fixed width format.
In the text file, I notice that the numeric fields were not padded with
leading zeros, but I need the leading zeroes.

I tried another method by importing from DB2 to a SQL table and when I run
query on the table, it doesn't show leading zeroes as well.( In DB2, the data
are with leading zeroes)

Has anyone got any idea on the above ? thnks.


In DB2 I assume you could write a query that fomatted the data first, or
it is definitely possible in T-SQL, e.g.

SELETCT RIGHT('0000000000' + CAST(NumericCol AS varchar(10), 10) AS
NumericCol) FROM Table

Or

you could do this formatting in an ActiveX Script Transform, using some
VBScript, e.g.

DTSDestinatination(1).Value = Right("0000000000" +
CStr(DTSSource(1).Value), 10)

--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.