I got a request that I modify a million applications (maybe a slight exaggeration) to have them all sort a certain field so that all values which start with ( show up at the bottom. Of course they want the top of the list to be ascending. So I decided the best way to do this is replace the () values with something that would perform the same delineation of text but sort the way I want. I chose char(171) and char(187) to do it. But when I sort, even though the decimal value for that character is higher - it sorts above regular letters.
Here's my test code. Can anyone explain why this doesn't sort - and a way I could do this without making changes in a ton of sprocs?
select
'(expired)'
Union
select
char(171) + 'expired' + char(187)
Union
select
'expired'
Union
select
'[expired]'
Union
select
'|expired|'
Union
select
'<expired>'
order by 1
Here's my test code. Can anyone explain why this doesn't sort - and a way I could do this without making changes in a ton of sprocs?
select
'(expired)'
Union
select
char(171) + 'expired' + char(187)
Union
select
'expired'
Union
select
'[expired]'
Union
select
'|expired|'
Union
select
'<expired>'
order by 1