In my program I need to add leading zero to the column : " pagenumber" which is having the values from 0 to 99.
I have used below query :
select '0' + cast(pagenumber as varchar) tablename
output : 00
It is working fine but when I tried to use condition in my query as
(since i need to add leading zero only to the single digit numbers)
select pagenumber =
case when pagenumber < 10 then '0' + cast(pagenumber as varchar)
Im getting output as : 0
The output generated is not having leading zeros.
I tried using right('0' + convert(varchar,pagenumber) , 2) as pagenumber but I have the same issue as described above.
I have spent more than a day but couldn't figure out where the issue is. Can someone plz help me with it.
View Complete Post