I have numbers that must be at least 7 digits long. For example:
0000001
123456789
0012345
Are all valid. I only need to pad the number with 0’s only if its length is below 7. How do I do this in SQL Server? The best I’ve been able to get is to pad the number if the length is less than 7, but above that, it starts to truncate the number instead.
1 Answer