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.
Trackback this post | Subscribe to the comments via RSS Feed