title: How to put single quotes around variables in a dynamic query
body: <p>I am trying to build a dynamic query. Initially @Query is set to the query string and then I want to dynamically add the WHERE clause. It works, except it isn't putting the single quotes around the strings in this case @val. This causes an error. How do I include the single quotes so that it adds them correctly?</p>
  
  <p>This is what I've tried:</p>
  
  <pre><code>SET @Query = @Query + ' WHERE ' + '' + @param + ' ' + @operator + ' ' + '' + @val + '' ;
  </code></pre>
  
  <p>Thanks!</p>