2

Is there any SQL function to convert the number in two digit numbers so, I can get 01 for 1.

hsuk
  • 6,770
  • 13
  • 50
  • 80

3 Answers3

9

You need to convert the value into string. You can use LPAD() for this,

John Woo
  • 258,903
  • 69
  • 498
  • 492
4

It would be:

SELECT LPAD(1, 2, '0');

Live Demo

Vishal Suthar
  • 17,013
  • 3
  • 59
  • 105
0

There is a way to do what you ask. Here is a post that explains it, assuming you are using SQL Server

Formatting Numbers by padding with leading zeros in SQL Server

Community
  • 1
  • 1
someuser
  • 47
  • 3