I am trying to query a column of type (int) into a string of format (000). For example: If the column value was 1 then the output of the query should be 001
Try this:
select right('000' + convert(varchar(3), intcolumn), 3) from yourtable
Note that the output is of type varchar
. If you will need this output as a number somewhere else, I would suggest doing the formatting in your UI code and keeping it as a number in the query.