Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to convert int lines into the format I want in sql, such as converting 1 into' 001',
How to convert int lines into the format I want in sql, such as converting 1 into' 001',
1 & gt; Select RIGHT( '000'+CAST( 1 as varchar), and 3) as.

2> go

a

-

00 1

(1 line affected)

The algorithm is

1。 First, convert 000+ your number into a character type. The provisional result here is 000 1.

2。 The result of intercepting the three characters on the right is 00 1.