I have an alarm trigger, and if this alarm trigger = 1, I want the value of the other column to be NULL. For example, I will create a simple table of what I'm trying to explain.
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
source share