declare @t table (mystr varchar(100) primary key)
insert into @t values ('-'),('a'),('--b'),('-a-')
select * from @t order by mystr
I got output as '-' , 'a','-a-','--b'
Ascii value of - is 48 and 'a' is 97. so its correct that - should come first.
Ordering in first 2 rows is correct. But what about ordering of last 2 rows, --b should come first, then -a- needs to come, as first character is same for both strings and second character, is lesser for "--b" compared to "-a-"
Why its happening like that???
This is the collation i am using "Latin1_General_CI_AI" . Windows collation.....
View Complete Post