Re: to append zeroes to left of a value

Re: to append zeroes to left of a value

 

  

This is something I have used to put zeroes on the front of a number....


substring('000000000', 1, 9 - len(Cast(fieldname AS char))) +
rtrim(Cast(fieldname AS char)) AS fieldname,

note:
substring('000000000', 1, 9 - the number of zeroes in quotes is the
number of positions of the field
the 9 is then length of the field













"Chiranjeev
Mukherjee "
<db2udbdba-ezmlms To
hield-x88653214.x "LazyDBA Discussion"
[Email Address Removed] <[Email address protected]
A.com> cc

11/28/2005 06:21 Subject
AM to append zeroes to left of a value










Hi gurus,

My problem is as follows:



I have a Numeric field ARTICLE_NBR of length 9.

Some of the articles are of length less than 9.

Suppose mys article no is : 123456

In my output I need it as : 000123456.



I need a query for this urgently.

Please if anyone can help me........







Regards

Chiranjeev

N

'We Stop playing not because we grow old,we grow old because we stop
playing'





---------------------------------------------------------------------
PLEASE CLICK REPLY-ALL TO SEND A REPLY TO EVERYONE
website: http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html




DB2 & UDB email list listserv db2-l LazyDBA home page