| Business Application Development with: SQL Server, C#, VB, VB.Net, ASP, ASP.Net, and XML |
| N | S |
Novick Software Management • Design • Programming • Training • Consulting |
|
|
News Links Schedule Site Map Contact |
|
Tips and Tricks for: SQL Server
The Problem: The DISTINCT clause is case insensitiveBy default the DISTINCT clause is case insensitive, at least on a case inseneitive instance of SQL Server. I ran into a situation where I was looking for all casings of a particular column, in order to fix them. Solution: The COLLATE clause can make any string operation case sensitive.The solution turned out to be pretty easy, use a COLLATE clause with a case sensitive collation. Here's a sample query with both case senstive and case insensitve collations. The data is all in the example, so give them a try.
select distinct (Item)
COLLATE
sql_latin1_general_cp1_cs_as All that is different in the next query is the name of the collation:
select distinct (Item)
COLLATE
sql_latin1_general_cp1_ci_ai
|
|
|
Copyright © 2003-2008 Novick Software, Inc. | Terms of Use | Privacy Policy | Nice Things People Say| |