Solved

Case insensitive search

Posted on 2001-07-25
6
234 Views
Last Modified: 2012-05-04
HI all..

I am working with SQL 2000 and have a search problem. In the past I used to be able to do a search with out worring about case, but the server here seems to be case sensitive.

A simple query like

select * from staff
where
 Name LIKE 'g%'

will not return the name 'Graeme'. it wants a 'G'.

My Question is - how do I perform a case-insenitive search in my query?

Thanks
0
Comment
Question by:ggets
[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
6 Comments
 

Expert Comment

by:isond
ID: 6316672
Try

select * from staff
where
Name like '[Vv]%'

Darren.

0
 

Expert Comment

by:isond
ID: 6316676
Sorry that last post does not seem clear. The Vv looks like W.

Hear it is again.
Try

select * from staff
where
Name like '[Gg]%'

Darren.

0
 
LVL 3

Accepted Solution

by:
ibro earned 50 total points
ID: 6316746
Try this:

select * from staff
where
upper(Name) LIKE 'G%'

But if you want to imporove performance in cases like this, always store the names in upper (lower) case, so you will gain performance from index search.
hope this helps
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
LVL 4

Expert Comment

by:mcmahon_s
ID: 6316747
Try:

SELECT * FROM STAFF
WHERE UPPER(NAME) LIKE 'G%'
0
 
LVL 4

Expert Comment

by:mcmahon_s
ID: 6316748
oops, ibro beat me to it
0
 

Author Comment

by:ggets
ID: 6318210
This works for me..

Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

635 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