Solved

Case insensitive search

Posted on 2001-07-25
6
188 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
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

760 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now