Solved

Case insensitive search

Posted on 2001-07-25
6
199 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
I have a large data set and a SSIS package. How can I load this file in multi threading?
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.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

932 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

10 Experts available now in Live!

Get 1:1 Help Now