My desire format

Microsoft SQL Server

Hi everybody,
I need to have an Integer value of one of my columns in this format:
'0000000'.
For example i want 123 to be considered as '0000123'. what is the function
for this conversion.
hi,
formatting is usually performed at the client level, as you know that this
kind of stuff performs a data type conversion, in this case a numeric to
string...
anyway, assuming you know the desired length of the pad(ding), you can play
with the string functions as well...

SET NOCOUNT ON
DECLARE @t TABLE ( num int )
INSERT INTO @t VALUES ( 1 )
INSERT INTO @t VALUES ( 10 )
INSERT INTO @t VALUES ( 100 )
INSERT INTO @t VALUES ( 1000 )
INSERT INTO @t VALUES ( 10000 )

SELECT RIGHT( REPLICATE ( '0' , 5 ) + CONVERT (varchar , t.num) , 5 ) AS
[Formatted num]
FROM @t t
--<--------
Formatted num