January 31, 2008 at 8:47 am
I need a little help with creating trigger. I am trying to update a particular field in one table after a change is made to a field in another table.
Here is the scenario:
A user will update a field;this field will become a null value. At this point, I would like a field in another table to become blank.
I think my issue is that the table that is being updated by the user does not directly link to the table being updated after the trigger.
Here is what I have:
CREATE TRIGGER reset_Assign
ON 1sttable FOR UPDATE
AS
Begin
IF update(hCurrentCamRule) /*field from 1sttable */
IF NULL = (Select i.hCurrentCamRule From inserted i)
IF 'Garage' = (Select i.sDesc from Inserted i)
IF Exists (Select * from 2ndtable b Inner join inserted i2 on i2.hCurrentCamRule = b.hMy
join 3rdtable c on c.hCode = b.htenant)
UPDATE 3rdtable set sfield = ''
From 3rdtable c2 Join 2ndtable b2 on c2.hCode = b2.htenant join inserted i3 on i3.hCurrentCamRule = b2.hMy
END
Any help would be appreciated.
Thanks!
Viewing 0 posts
You must be logged in to reply to this topic. Login to reply