2

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

hsuk
  • 6,571
  • 12
  • 48
  • 80

3 Answers3

8

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

John Woo
  • 249,283
  • 65
  • 481
  • 481
4

It would be:

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

Live Demo

Vishal Suthar
  • 16,685
  • 2
  • 55
  • 101
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