I've found a very easy way for integer padding in SQL 2005.
cast(replace(str(INT_N, 3),' ','0')as char(3)),
where INT_N is an integer number, and 3 - the size of the string required, e.g
DECLARE INT_N int
SET INT_N = 33
SELECT cast(replace(str(INT_N, 8), ' ', '0') as char(8)) as PADDED_INT
Will result in:
PADDED_INT
00000033.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment