How to search for the special character (%) in SQL Server 2008

I have an entry with a value of Jacj%25011987 . I wanted to find the entry with % as a character in the string.

I wanted to find this entry using the Like clause in where .

I tried these queries, but they did not work:

 Select * From Table1 With (Nolock) Where Column1 like '%\%%' Select * From Table1 With (Nolock) Where Column1 like '%'%%' 

Thanks Parag

+6
source share
1 answer

I think the easiest way is to use [] :

 where column1 like '%[%]%' 

You can also use escape with what you like for the escape character:

 where column1 like '%!%%' escape '!' 

This is more portable because escape is part of the ANSI standard.

+10
source

All Articles