title: SQL Query - Incorrect syntax near the keyword 'LIKE'
body: <p>The following query is giving an error at
  'CASE WHEN NOT LIKE' (Msg 156, Level 15, State 1, Line 14
  Incorrect syntax near the keyword 'LIKE')</p>
  
  <pre><code>SELECT     
   TimeStamp, 
   TimeStampNS, 
   ISNULL(TagName, 'NoTag') AS TagName, 
   Message, 
   ConditionName, 
   ISNULL(TagName, 'NoTag') + '.' + ConditionName AS Source, 
   CENTUMMsgId, 
   StationName,  
   ISNULL(AlarmLevel,5) AS AlarmLevel,
   ActiveTime, 
   ActorID, 
   ISNULL(AlarmOff,0) AS AlarmOff,
   CASE WHEN  NOT LIKE '% ACK%' AND CENTUMMsgId IN (4353, 4355, 4609) THEN 1 ELSE 0 END AS RaiseAll, 
      CASE WHEN  LIKE '% ACK%' THEN 1 ELSE 0 END AS Acknowledge, 
      CASE WHEN CENTUMMsgId IN (4354, 4356, 4358, 4614) AND Message NOT LIKE '% ACK%' THEN 1 ELSE 0 END AS Normal, 
   PlantHierarchy, 
   'EXAOPC' AS SourceType
  FROM QHistorianData.dbo.vEXAOPCCSProcessAlarm
  </code></pre>
  
  <p>Do you guys know what's going on... I think I have eveything correct there.</p>
  
  <p>Thank you in advance for any help.</p>