title: Dynamic SQL with LIKE condition
body: <p>I've tried a number of different combinations of the below code, but I keep getting the same error.  </p>
  
  <p>Previous solutions I've found, <a href="https://stackoverflow.com/questions/24596886/the-data-types-nvarchar-and-varchar-are-incompatible-in-the-modulo-operator">such as this one</a>, didn't have the extra complexity of being embedded in dynamic SQL. Any help would be greatly appreciated.</p>
  
  <p>Code:</p>
  
  <pre><code>DECLARE @table as NVARCHAR(25) = 'proposals'
  DECLARE @column as NVARCHAR(25) = 'daypart'
  DECLARE @modulo as NVARCHAR(5) = ''%''
  
  DECLARE @COL_SELECT AS NVARCHAR(2000)
  
  SET @COL_SELECT = 'SELECT DISTINCT column_name 
                     FROM information_schema.COLUMNS
                     WHERE table_name = ' + @table + '
                       AND column_name like ' + @modulo + @column + @modulo + ''
  
  EXEC(@COL_SELECT)
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <p>Msg 402, Level 16, State 1, Line 6<br>
    The data types varchar and varchar are incompatible in the modulo operator.</p>
  </blockquote>