Posted by Simon Hayes on 09/13/05 12:47
1 is an integer, '01' is a string. If you want to pad your integers
with leading zeroes, it would be best to do it on the client side, as
that's usually the best place for presentation and formatting. If you
really need to do it when you retrieve the values from the database
then this is one possible way:
select
case when IntColumn between 0 and 9 then '0' + cast(IntColumn as
char(1)) else cast(IntColumn as varchar(10)) end
from dbo.MyTable
Simon
[Back to original message]
|