troubleshooting Question

SQL Trigger - update - add date to date field when status field changes to value 2

Avatar of donhannam
donhannamFlag for New Zealand asked on
Microsoft SQL Server
2 Comments1 Solution396 ViewsLast Modified:
I want to set up a trigger on a table so that when the status field is changed to 2 (will be from either 0 or 1) that the trigger inserts the date the status was set to 2 in a seperate field say StatusUpdatedDate. I do not want this updated if another field on this record is update so carn't just check the field value = 2 and then update date with getdate.
Would like to read the status of the record before it is updated to compare. I can get the value of the inserted record but not sure how to get the value of the record before updated - I guess SQL deletes and inserts?.
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros