I have a record with a value Jacj%25011987
. I wanted to search the record with %
as a character in a string.
I wanted to search this record using the Like
in where
clause.
I tried these queries, but they didn't work:
Select *
From Table1 With (Nolock)
Where Column1 like '%\%%'
Select *
From Table1 With (Nolock)
Where Column1 like '%'%%'
Thanks Parag
The LIKE operator is used in a WHERE clause to search for a specified pattern in a column. There are two wildcards often used in conjunction with the LIKE operator: The percent sign (%) represents zero, one, or multiple characters. The underscore sign (_) represents one, single character.
I think the easiest way is to use []
:
where column1 like '%[%]%'
You can also use escape
with whatever you like for the escape character:
where column1 like '%!%%' escape '!'
This is more portable, because ESCAPE
is part of the ANSI standard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With