Solved

Sql query using 'like' and ignore case

Posted on 2011-09-15
7
476 Views
Last Modified: 2012-05-12
I would like to obtain results using the 'like' word but I want it to ignore the case in the results.

For example
select * from table1 where column1 like 'aBcD'
should return all the rows where column1 is ABCD, abcd, etc.

thanks,
Anu
0
Comment
Question by:Anandhi1
7 Comments
 
LVL 38

Accepted Solution

by:
Aaron Tomosky earned 250 total points
ID: 36544452
If you are using the default Charset SQL_Latin1_General_CP1_CI_AS the ci stands for case insensitive.
0
 
LVL 1

Author Comment

by:Anandhi1
ID: 36544496
Currently my query
select * from table1 where column1 like 'ABCD%' returns only the 'ABCD' not 'abcd' .

Is it possible to do in SQL?

0
 
LVL 13

Expert Comment

by:LIONKING
ID: 36544609
You can upper everything and give it a try, something like:

select * from table1 where UPPER(column1) like UPPER('ABCD%')
0
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
LVL 1

Author Comment

by:Anandhi1
ID: 36544771
That worked but the query took a long time to execute. It took a minute instead of a second.

Do we have any other solution?

thanks,
Anu
0
 
LVL 12

Expert Comment

by:jagssidurala
ID: 36545140
0
 
LVL 59

Assisted Solution

by:Kevin Cross
Kevin Cross earned 250 total points
ID: 36545145
That is because you wrapped the column1 with a function. Try it with COLLATE. Using aaron's Charset:

SELECT *
FROM table1 
WHERE column1 COLLATE SQL_Latin1_General_CP1_CI_AS LIKE 'ABCD%';

Open in new window

0
 

Expert Comment

by:sath350163
ID: 36546348
If column1 has index on it, doing UPPER(column1) will prevent that index from being used.
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

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

15 Experts available now in Live!

Get 1:1 Help Now