title: How to escape a string for use with the LIKE operator in SQL Server?
body: <p>I am looking for something that works in SQL Server similar to the <code>@</code> symbol in c# which causes a string to be taken as it's literal.  Eg:</p>
  
  <pre><code>string text = "abcd\\efg";
  Output of text = abcd\efg
  
  string text = @"abcd\\efg";
  Output of text = abcd\\efg
  </code></pre>
  
  <p>Note how the @ affected the string to take every character as is.</p>
  
  <p>Now I am not sure this is possible but here is my issue and maybe there is a better way to solve this.  Consider the following basic query:</p>
  
  <pre><code>SELECT [Name] 
    FROM [Test] 
   WHERE [Name] LIKE (@searchText + '%')
  </code></pre>
  
  <p>My issue is if they put a <code>%</code>, <code>_</code> or any other of those special characters that can affect my like clause.  I want the match to act just like a 'starts with' function.  So is there anything I can apply to the @searchText to say take this literally or is there possbibly a better solution that I am not thinking of?</p>
  
  <p><strong>Edit:</strong> I do not want the solution to be client side cleaning.  I need this stored proc to work without relying on the data being passed in being cleaned.</p>