title: How to handle special characters in SQL Server Select query
body: <p>I have following data in table</p>
  
  <pre><code>create table Manager(id int, managerid varchar(10) , managername varchar(50))
  
  insert into Manager(id, managerid, managername)
  values (1, 'A1', 'Mangesh'), (2, 'A''2', 'Sagar'), (3, '_C[%]3', 'Ah_mad'),
         (4, 'A4', 'Mango'), (5, 'B5', 'Sandesh')
  </code></pre>
  
  <p>I am using stored procedure to get the result on the basis of given characters. One of the users want to search with <code>c[%]</code>. I am able to handle <code>%</code> with <code>[%]</code> but if string is having <code>[%]</code> then I am unable to find it.</p>
  
  <p>I tried with following query </p>
  
  <pre><code>declare @str varchar(100)='C[[%]'
  
  SELECT m.* 
  FROM Manager m 
  WHERE m.managerid LIKE '%'+@str+'%'
  </code></pre>
  
  <p>This way I am able to get the result but in this case input is <code>C[%</code> only. I replaced <code>%</code> with <code>[%]</code> in my stored procedure parameter. But if input is <code>C[%]</code> then my query is not returning anything.</p>