I have the following table A:
id ---- 1 2 12 123 1234
I need to left-pad the id values with zero\'s:
id
id ---- 0
This is what I normally use when I need to pad a value.
SET @PaddedValue = REPLICATE('0', @Length - LEN(@OrigValue)) + CAST(@OrigValue as VARCHAR)