I have values like " 11(space)", "109", "X(space)(space)", "9(space)(space)", "15(space)" etc. in a column called MyCode that is varchar(3).
When I order them I have a prolbme like 11 appears before 109 when I ORDER them in ASC order.
I want to align the values to right by adding empty char in front so that ORDER would result:
" 11"
..
"109"
Question: How can I write my SELECT MyChar FROM MyTable so that for a value "1(space)(space)" it should return "(space)(space)1" etc. ?
@gbn: Your answer did what I needed but the output didnt change: