I have the below SQL statement. What I am trying to do is add two values based on conditions. So if
SET @IsEVMPresent = 1
SET @IsUCMPresent = 1
SET OneTimeExpense = (CASE WHEN @IsUCMPresent = 1 THEN 75 * 70 END) +
(CASE WHEN @IsEVMPresent = 1 THEN 75 * 8 END)
WHERE ItemId = 'ECS' OR ItemId = 'UCM'
@IsUCMPresent = 1
@IsEVMPresent = 1
You need to add an else clause to your case statements:
UPDATE #MainData SET OneTimeExpense = (Case When @IsUCMPresent = 1 Then 75 * 70 Else 0 End) + (Case When @IsEVMPresent = 1 Then 75 * 8 Else 0 End) Where ItemId IN('ECS','UCM')
Without them it will return null and Sql cannot add a number and null.