title: How to use an IN operator in a dynamic query
body: <p>I would like to use the in operator in a dynamic query . At the moment I need someone to point in in the right direction as to how to structure the apostrophes for separating values so that they don't interfere with the apostrophes for the dynamic query structure. This is a section of the query that is giving problems so what I need to know is how where to place the separator so that all of values can be included in dynamic query format as opposed to the regular query format that I have right now</p>
  
  <pre><code>WHERE ai.ImNumber != me.Company 
      AND me.ID IN ('value1','value2','value2','value3','value4','value5')' 
  </code></pre>
  
  <p>My Query is</p>
  
  <pre><code>SET @SQLString = 'select me.EventID , ai.AggregateInfo, '''+@DateBegin+''' AS DateBegin, '''+@EDateEnd+''' AS DateEnd 
  FROM tbl_MajorEarners me 
  INNER JOIN tbl_currentearners e ON e.EventID = me.EventID 
  INNER JOIN tbl_AggregateInfo ai ON ai.AggregateID = cs.ItemID 
  WHERE ai.ImNumber != me.CompanyNUmber 
  AND me.ID IN ('value1','value2','value2','value3','value4','value5')'
  </code></pre>