Monday

sql add zeros in front of number

Right function can be use to perform this formatting.For example - if we have table with
column containing numbers and we have to add leading zeros to these number we can do following:
 
SELECT * FROM Numbers;
Num
12
112
12
122
122

5 row(s) affected.

Formatting:
SELECT RIGHT('00000'+ CONVERT(VARCHAR,Num),6) AS NUM FROM Numbers;

NUM
000012
000112
000012
000122
000122
5 row(s) affected.


No comments:

make ubuntu business casual

to make ubuntu business casual - make it black remove background: gsettings set org.gnome.desktop.background picture-options ...