Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 case sensitive searching with LIKE comparisons

Author  Topic 

billsox
Yak Posting Veteran

74 Posts

Posted - 2002-03-29 : 12:20:37
Hi -- I've got a table that contains various sentences in one field like:

"Mary has one apple."
"These apples are delicious."
"An apple a day keeps the doctor away."
"Apples to Zebras."
"Apple of my eye."

I'm trying to perform a case-sensitive string search such that I want to look for the word "Apple" and return only the last two records. I thought this could be accomplished by converting my search string and search field to varbinary values and have matching values returned but this only works for exact matches. Thus, "Apples to Zebras" would not be returned. Converting the entire search field to varbinary would rarely match the varbinary value of the smaller search string. Anyone have any ideas on how to combine "LIKE" comparisons with case sensitive searches? Thanks in advance.

Bill

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2002-03-29 : 13:55:50
The issue is collation; BOL has fairly extensive articles on it.

If you're running SQL 2K, you can specify a COLLATE clause in your select statement ( I believe ) that will effect a case-sensitive search if your default collation is case-insensitive.

setBasedIsTheTruepath
<O>
Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2002-12-02 : 01:57:33
select sentence
from table
where sentence collate Latin1_General_BIN like '%Apple%'

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page
   

- Advertisement -