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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trigger based on data change - how?

Status
Not open for further replies.

phbrady

Programmer
Oct 17, 2003
41
US
Maybe a trigger isn't best for this. I have a field called Status in my Projects table. I want to update the StatusChanged date/time field only when the Status of the Project has been changed.
Either way, if I were to use a trigger, how would I check to see what the value of the Status field is BEFORE the field is updated and then compare it to the field's value afterward and update the StatusChanged field only if there is a difference? Or perhaps I should have a completely separate status table with ProjectID, status and statuschanged fields and fire off a stored procedure using a trigger every time the Projects table is updated - which do you think would be the most efficient?

Thanks!

P
 
Read up on using logical tables Inserted/Deleted in BOL.

Also check this thread (thread183-1107067) for updating the status field only when there is a change.

Regards,
AA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top