Brad Gough Brad Gough - 3 months ago 10
SQL Question

SQL Server using LIKE to search column firstname for " " characters

I am trying to query a database table to return all records where the firstname column contains the characters

" "
.

For example
Lars-Erik "Molle"
.

I tried this:

SELECT * FROM [bgtest].[dbo].[cuscon] WHERE firstname LIKE '%Lars-Erik%'


and that returned the record this was just me making sure I was doing it right then I replace the
Lars-Erik
with
""
and ofcourse as it will now look like
'%""%'
it doesn't like it and returns nothing.

Any ideas I've tried CONTAINS and LIKE and can't figure out a way to do it.

Thanks

Answer

It looks like you need query something like:

SELECT * FROM [bgtest].[dbo].[cuscon] WHERE firstname LIKE '%"%"%' 

Because %""% will search for two subsequent " characters only.