How do I pad an Integer to 4 digits with leading zeros?
June 6, 2008
Run the following SQL code:
SELECT RIGHT(’0000′ + YourValue), 4)
Note: To pad to a different number of digits, replace the ‘0000′ and the 4 as appropriate, eg. SELECT RIGHT(‘00000000′ + YourValue), 8) will pad to 8 digits.
Entry Filed under: SQL Scripts. Tags: integer, leading, pad, pad values, padding, RIGHT, sql.
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed