Reputation: 43
I am trying to update a field with different conditions in where. Actually I have the next instructions:
Update StmHistItm Set SHI_nPayable = @minPayable where SHI_iItemPK = @minrecno
Update StmHistItm Set SHI_nPayable = @maxPayable where SHI_iItemPK = @maxrecno
Is there a way to do this two instruction in just one?
Upvotes: 2
Views: 15199
Reputation: 311393
You could use a case
expression and combine the where
clauses:
UPDATE StmHistItm
SET SHI_nPayable = CASE SHI_iItemPK
WHEN @minrecno THEN @minPayable
WHEN @maxrecno THEN @maxPayable
END
WHERE SHI_iItemPK IN (@minrecno, @maxrecno)
Upvotes: 4