views:

219

answers:

2

I'm looking to compare two varchars in SQL, one would be something like Cafe and the other Café is there a way in SQL that will allow the two values to be compared. For instance:

SELECT *
FROM Venue
WHERE Name Like '%cafe%'

So if there is a venue with the name Big Bobs Café Extraordinaire it would be included in the result set?

+4  A: 

By applying a specific collation order to your select:

SELECT * 
FROM Venue 
WHERE Name COLLATE SQL_Latin1_General_CP1_CI_AI Like '%cafe%' 

The CI stands for "Case Insensitive" and AI for "Accent Insensitive".

Mitch Wheat
Ah, that's what all those silly characters on the end mean. I know it's daft, but that helps a huge amount. Somehow, for me, DB collation always seems to bring brain fog with it.
ilivewithian
@ilivewithian: I think everyone gets the same "brain-fog", including me.
Mitch Wheat
+5  A: 

Coerce to an accent insensitive collation

You'll also need to ensure both side have the same collation to avoid errors or further coercions if you want to compare against a table variable or temp table varchar column

and because the constant value will have the collation of the database Update: only for local variables, not for constants nope, not even then

SELECT *
FROM Venue
WHERE
   Name COLLATE Latin1_general_CI_AI Like '%cafe%' COLLATE Latin1_general_CI_AI
gbn