December 5, 2001 at 9:00 am
OK - this may be fairly basic, but bear with me guys..
I want to build a trigger that emails a selected user when a row is updated/inserted in a table... What I need to do is get a value from the inserted row (emailname),{inserted.emailname} set it a variable, (@emailname) and then check to see if the column was updated in the insert/update that fired the trigger. If so, send an email to @emailname...
All is OK, but I need the sequence of events to be
[1] update/insert occurs
[2] trigger fires and inserted *temp* table is populated
[3] trigger verifies that column value emailname is different/the same and takes appropriate action
[4] database write occurs
phew... all I really need is the trigger to fire and complete BEFORE the row is updated in the actual table
cheers
Mr Hutch
December 5, 2001 at 11:36 am
the trigger always fires before the update is complete. it is part of the transaction.
In the trigger, work with the inserted and deleted tables to determine the values you need. You can check them for different values or use Updated(column name) to see if a paticular column was updated. This DOES NOT show if the value was changed, just if an update occurred.
Steve Jones
December 5, 2001 at 12:51 pm
thanx a lot steve - already done part of this but let me just say that the site and the forums ROCK!!! I've just started a new position as a Developer, from a techie/DBA background and the info on your site is great - good to have so many people with experience on your side! - one day I may be able to post a reply!!!!!
keep it up and transatlatic thanx !
Mr Hutch
December 5, 2001 at 12:55 pm
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply