Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trigger Syntax 1

Status
Not open for further replies.
Jun 29, 2001
195
US
In the PersonAddress table in our HRIS db. I want the trigger to fire if the field Address OR City OR State OR Zip is updated. Right now I have it set up with a trigger on each field but there must be a way to consolidate them into one.

Any ideas. Thanks.
Ashley L Rickards
SQL DBA
 
Yeah, actually, I'm in the same situation. Anyone's thoughts would be greatly appreciated.
 
Hi there,
Within Triggers, we can use the UPDATE(col) function to determine if a particular column has been updated.

Here's a rough outline of how it works; it's easy to see what is happening.
---------------------------
CREATE TRIGGER MyNewTrigger
ON UserTable
FOR UPDATE
AS
If UPDATE(Address)
Begin
blah blah
END

If UPDATE(City)
Begin
blah blah
End

If UPDATE(State) or UPDATE(ZIP)
Begin
blah blah
End
--------------------------------
hope that helps,
bperry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top