Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

pad a number set in SQL query

$
0
0

I have a set of employee numbers ranging from 3-5 characters and need to pad them starting with a 1 and fill in the remaining space with zeros so they are 6 characters long. Ive used

SELECT LEFT('100'+ CONVERT(VARCHAR,EMPLOYEE),6) AS NUM FROM ls_apps.EMPLOYEE

which works fine until the numbers have 4 or more characters already. 


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>