title: How to use subquery in IN in a dynamic sql for varchar type
body: <p>Apparently I could not do the following:</p>
  
  <pre><code>DECLARE @sql VARCHAR(2000)
  
  SET @sql = 'SELECT es.* FROM emp_schedule es
  WHERE  es.work_status IN (' + (SELECT data_value FROM #absences) + ')'     
  
  exec sp_executesql @sql
  </code></pre>
  
  <p>column data_value is of type varchar and so is es.work_status. This query will give me error <em>"Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, &lt;, &lt;= , >, >= or when the subquery is used as an expression."</em> which makes sense since it is being used as expression in this one. Any ideas how I could implement this piece. Thanks guys.</p>