For example: instead of "1", you need "0001" displayed.
All this from SQL ...
I think this is an easy way of doing that:
select replicate('0', 6-len(convert(varchar(50), 'aaa'))) + convert(varchar(50), 'aaa')
You need to change the '6' if longer, and 'aaa' is your string ...
what do you think?
comment!
3 comments:
Thanks for this tip. This was very useful.
another way is :
select right(cast('000' as varchar(3))+cast('aa' as varchar(4)),4)
Very useful tip. Thanks a lot
sureshrw
Post a Comment