title: SQL INSERT (select) using CASE based on another columns value
body: <p>I have an alarm trigger, and if that alarm trigger = 1, I want the value of another column to be NULL.  For examples purposes, I'll create a simple table of what I'm trying to explain.</p>
  
  <pre><code>DECLARE @tmp TABLE ( ID INT, Value1 FLOAT, V1_Alarm BIT, Value2 FLOAT, V2_Alarm BIT)
  INSERT INTO @tmp
  SELECT (
  ID,
  CASE WHEN V1_Alarm = 1 THEN NULL ELSE Value1,
  V1_Alarm,
  CASE WHEN V2_Alarm = 1 THEN NULL ELSE Value2
  ) FROM SomeTable
  </code></pre>