6

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

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
rocky_pps
  • 143
  • 2
  • 2
  • 8
  • Here's [a link for reference](http://stackoverflow.com/q/712580/4780877), covers others databases besides sql-server. – Emacs User Nov 09 '15 at 18:58

1 Answers1

13

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.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786