I am using SQL Server Management Studio and trying to make a trigger that would after update of "order" table set "gift_id" column's values to "NULL" where the same row "reservation_id" column's value would be "0<" or NOT NULL".
Shorter explanation - if within the row "reservation_id"=NOT NULL then set "gift_id"=NULL.
I have come up with this, but I can't get this trigger right. Can someone give me a hint?
CREATE TRIGGER add_reservation
ON [dbo].[order]
AFTER UPDATE
AS BEGIN
UPDATE [dbo].[order]
CASE
WHEN [reservation_id] > 0
THEN SET [gift_id] = NULL
END
END
GO
Seems that there is a syntax error:
Msg 156, Level 15, State 1, Procedure add_reservation, Line 6
Incorrect syntax near the keyword 'CASE'.