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:

test smtp server with powershell

Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...