title: Using IF EXISTS with a CTE
body: <p>I want to check if a CTE table has record or null. But I always get error message 'Incorrect syntax near the keyword 'IF'' for the SQL below. Now there is no matching record in ADMISSION_OUTSIDE TABLE. The result of the SQl should print 'NOT OK'. Thanks,</p>
  
  <pre><code>WITH ADMISSION_OUTSIDE AS 
  (   .....
  .....
  )
  
  IF EXISTS (SELECT * FROM ADMISSION_OUTSIDE)
  PRINT 'OK'
  ELSE PRINT 'NOT OK'
  </code></pre>