leading zeroes

Database

leading zeroes

Hi all,

i trying to get in a 3 digit "INT" field, the leading zeroes. 

substantially i need to change "1" to "001" or "12" to "012" and so on.....

executing the query ....

SELECT

substr('000' + cast(ID_FD AS CHAR(3)),3) as ID_FD_modificato, ID_FDFROM DXDWH_IRION_VW.DWH_FD

i get something wrong

ID_FD_modificato               ID_FD

.00000000000000E 000      3

could you gently help me in this trouble?

2 REPLIES
N/A

Re: leading zeroes

+ is a numeric operator, only SQL Server uses it for string concat.

But you don't need any fancy calculation, simply use LPAD(ID_FD, 3, '0')

Teradata Employee

Re: leading zeroes

select 7 (format '999')(char(3))

This is other way