Hello,
I have numbers in a column:
1
5
9
10
15A
19
20
100
125
I am trying to pad leading 0's so the numerical part of each entry is 3 digits. If I just pad leading 0's I get this:
001
005
009
010
019
020
100
125
15A
By doing so, the 15A is out of order when sorting. The code I am running is:
Is there a way I can have SQL recognize the 15 part of the number to pad it with a 0 so it falls in line as 015A?
This is SQL 2000.
Thanks in advance!
I have numbers in a column:
1
5
9
10
15A
19
20
100
125
I am trying to pad leading 0's so the numerical part of each entry is 3 digits. If I just pad leading 0's I get this:
001
005
009
010
019
020
100
125
15A
By doing so, the 15A is out of order when sorting. The code I am running is:
Code:
select RIGHT('000' + convert(varchar(3),mytable.COL001), 3) from mytable
Is there a way I can have SQL recognize the 15 part of the number to pad it with a 0 so it falls in line as 015A?
This is SQL 2000.
Thanks in advance!