sqlsql-server

How to add leading zero when number is less than 10?


I have a column in my sql table. I am wondering how can I add leading zero to my column when my column's value is less than 10? So for example:

number   result
1     ->    01
2     ->    02
3     ->    03
4     ->    04
10    ->    10

Solution

  • format(number,'00')
    

    Version >= 2012