?
Solved

Is there a way to case sensitive DISTINCT query?

Posted on 2007-11-29
3
Medium Priority
?
1,155 Views
Last Modified: 2011-10-03
Hi,
My database is set to be case insensitive.
Is there a way to case sensitive DISTINCT query?
i.e.
My table Employees has columns Name and Email
Name       Login
George   10 AM
Tom        10 AM
Tom        11 AM
Tom        12 PM
TOM      10 AM
TOM      11 AM
TOM      1PM

When i query select distinct name from Employess, the result set is
George, Tom as expected.

How can I query so that result set is George, Tom, TOM?

Thanks
Jamie
0
Comment
Question by:jamie_lynn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 18

Expert Comment

by:Jinesh Kamdar
ID: 20379923
What DB are you using?
0
 
LVL 5

Accepted Solution

by:
ursangel earned 2000 total points
ID: 20380693
Im guesing its SQL server...
A default SQL Server installation is case insensitive, which means that SQL Server will not differentiate between upper and lower case characters/letters. By default SQL Server 2000 gets installed with case insensitive collation. You must change the collation of the server while installing, if you want case sensitiveness.
The work around for this is to convert the columns that need to be compared as Case sensitive into varbinary and do the comaprison.

select  distinct cast(a.name as varbinary(25))name into #Temp from employee a where
                  cast(a.name as varbinary(25)) in
                        (select distinct cast(b.name as varbinary(25))name  from employee b)  
Go

select cast(name as varchar(25)) name from #Temp
0
 
LVL 5

Expert Comment

by:ursangel
ID: 20380919
One easy way.

SELECT   distinct Name COLLATE Latin1_General_CS_AS
FROM      Employees
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question