Task

Express a number in decimal as a fixed-length string with leading zeros.



For example, the number   7.125   could be expressed as   00007.125.




DECLARE @n INT
SELECT @n=123
SELECT SUBSTRING(CONVERT(CHAR(5), 10000+@n),2,4) AS FourDigits
 
SET @n=5
print "TwoDigits: " + SUBSTRING(CONVERT(CHAR(3), 100+@n),2,2)
--Output: 05