title: Incorrect syntax near 'REPLACE'
body: <p>the following SQL statement shows solid results with PRINT but with EXEC, gives me Incorrect syntax near 'REPLACE' </p>
  
  <pre><code>USE EPDB
  
  DECLARE @Table as nvarchar(100)
  DECLARE @Column as nvarchar(100)
  DECLARE @Select as nvarchar(375)
  DECLARE @Where as nvarchar(275)
  
  SET @Table = 'TableABC'
  SET @Column = 'ColumnABC'`enter code here`
  SET @Select = 'SELECT * FROM INFORMATION_SCHEMA.COLUMNS'
  SET @Where = 'CRITERIA = ''VALUE'''
  
  
  -- EXEC ('SELECT * FROM INFORMATION_SCHEMA.COLUMNSWHERETABLE_NAME = ' + @Table + '''')
  
  PRINT @Select + ' WHERE ' + REPLACE(REPLACE(@Where,'CRITERIA','TABLE_NAME'),'VALUE',@Table)
  
  EXEC (@Select + ' WHERE ' + REPLACE(REPLACE(@Where,'CRITERIA','TABLE_NAME'),'VALUE',@Table))
  </code></pre>
  
  <p>not sure what is going on here </p>