Avatar of Jeff Jones
Jeff Jones

asked on 

Format numbers in 2008

Have a random numberic values that needs to be converted to 4 characters.  Depending on the number, the padding of the zero's on either the right or the left will vary.  For instance = a value of 147.8 will be converted to 1478 (decimal point is stripped out).  If the value is 0.9 the converted value needs to be 0009.  However, there could also be an instance where the value is 7.8 and the converted value would be 0780.

If this were in 2012, I think I could use the Format() function, but since that's not an option I need some help in how I can accomplish this as efficiently as possible.
Microsoft SQL Server 2008* T-SQL

Avatar of undefined
Last Comment
Sharath S

8/22/2022 - Mon