Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 7,2000
»
General
»
Creating triggers
Creating triggers
Rate Topic
Display Mode
Topic Options
Author
Message
Tammy Robinson
Tammy Robinson
Posted Thursday, January 31, 2008 8:47 AM
SSC 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:
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!
Post #450001
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.