Re: need leading zeros when export to text file
From: Darren Green (darren.green_at_reply-to-newsgroup-sqldts.com)
Date: 12/13/04
- Next message: Venkatesh Iyengar: "Detecting a User defined CustomTask"
- Previous message: Jess: "need leading zeros when export to text file"
- In reply to: Jess: "need leading zeros when export to text file"
- Next in thread: Jess: "Re: need leading zeros when export to text file"
- Reply: Jess: "Re: need leading zeros when export to text file"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 13 Dec 2004 06:49:57 +0000
In message <254C5E54-6104-4060-9938-1008D5FA3C1D@microsoft.com>, Jess
<Jess@discussions.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
- Next message: Venkatesh Iyengar: "Detecting a User defined CustomTask"
- Previous message: Jess: "need leading zeros when export to text file"
- In reply to: Jess: "need leading zeros when export to text file"
- Next in thread: Jess: "Re: need leading zeros when export to text file"
- Reply: Jess: "Re: need leading zeros when export to text file"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|