Imran Akram's blog

Let's talk about life, technicalities, career opportunities, current affairs and a lot more!

how to convert an integer to string and left pad it with zero's?

Here’s a quick and simple way of converting an integer to string (varchar) and left pad it with leading zeros like 00012. This example will get the result in 5 digits select right(’00000′ + cast(yourfield as varchar(5)), 5)

  • Share/Bookmark