sql padd let with zeros

Solutions on MaxInterview for sql padd let with zeros by the best coders in the world

showing results for - "sql padd let with zeros"
Jenessa
16 Jan 2020
1If you want nulls to show as '000' 
2It might be an integer -- then you would want
3
4SELECT RIGHT('000'+CAST(field AS VARCHAR(3)),3)
5
6As required by the question this answer only works 
7if the length <= 3, if you want something larger you need 
8to change the string constant and the two integer constants t
9o the width needed. eg '0000' and VARCHAR(4)),4