I need a trigger that update to Null a column everytime another column is changed.
This is what I have now:
ALTER TRIGGER [dbo].[ERROR_CLEAR] ON [dbo].[contact] AFTER UPDATE AS BEGIN SET NOCOUNT ON; IF UPDATE (NAME) BEGIN UPDATE contact SET ERROR = Null FROM contact c2 INNER JOIN Inserted I ON c2.ID = I.ID INNER JOIN Deleted D ON d.ID = c2.ID WHERE c2.NAME <> I.NAME AND I.NAME <> D.NAME END END
I'm testing like this:
UPDATE contact SET NAME = 'John' WHERE NAME = 'Paul'
But its not working and I'm running out of ideas. Any help?