Have a table with this schema
Performers (PerformerID, PerformerName, Street, City, State, Zip, ActivityID)
I need to define a trigger to prevent deletion if the ActivityID of the deletion is unique for the table. In other words, if the someone try to delete a Performer when he/she is the only one with a certain ActivityID for the entire table, trigger should fire and avoid the deletion. Otherwise trigger shouldn't interrupt.
I tried following code but it gives me a syntax error.
CREATE TRIGGER deletePerformer BEFORE DELETE ON Performers
FOR EACH ROW
BEGIN
If (Performers.ActivityID FROM INSERTED != Performers.ActivityID FROM Peformers)
Begin
RAISERROR ('Deletion is Not Allowed!', 16, 1)
Return
End
END;
Any Help is much Appreciated.