Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Creating triggers Expand / Collapse
Posted Thursday, January 31, 2008 8:47 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, October 16, 2012 7:46 AM
Points: 31, Visits: 37
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:

ON 1sttable FOR UPDATE


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


Any help would be appreciated.

Post #450001
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse