Breaking News
Loading...
29/08/2013

Between & Collation

If you run the script as follows on SQL 2012, what results you will get?
create table #test(name varchar(10) COLLATE Latin1_General_CS_AS);
Go
insert #test ( name ) values ( 'B');
insert #test ( name ) values ( 'b');
insert #test ( name ) values ( '.B');
insert #test ( name ) values ( 'b.');
insert #test ( name ) values ( 'C');
insert #test ( name ) values ( 'c');
insert #test ( name ) values ( 'D');
insert #test ( name ) values ( 'd');

select name from #test where name between 'B' and 'd' order by 1;

drop table #test;

Choose your answer:


Correct answer: 

B, b., c, C, d

Explanation: 

Per MSDN: Distinguishes between uppercase and lowercase letters. If selected, lowercase letters sort ahead of their uppercase versions. If this option is not selected, the collation will be case-insensitive. That is, SQL Server considers the uppercase and lowercase versions of letters to be identical for sorting purposes. You can explicitly select case insensitivity by specifying _CI.

0 comments:

Post a Comment

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

 
Toggle Footer