Unique values with Collations.

vishalneeraj-24503
Posted by vishalneeraj-24503 under Sql Server category on | Points: 40 | Views : 194
Collations in SQL Server provide sorting rules,case,and accent sensitivity properties for our data.
select distinct (Item) COLLATE sql_latin1_general_cp1_cs_as 
FROM (
select 'abcd' item
union all select 'ABCD'
union all select 'defg'
union all select 'deFg') items

Output:-
ABCD
abcd
deFg
defg


select distinct (Item) COLLATE sql_latin1_general_cp1_ci_as 
FROM (
select 'abcd' item
union all select 'ABCD'
union all select 'defg'
union all select 'deFg') items


Output:-
ABCD
deFg

Comments or Responses

Login to post response