troubleshooting Question

Need an update trigger to log last update to table

Avatar of kevindockerty
kevindockerty asked on
DatabasesMicrosoft SQL ServerSQL
10 Comments1 Solution484 ViewsLast Modified:
Is there a quick and easy way to have a datetime column in a table that will catch 'lastupdated' date and time. I can do this for 'inserted'/'created' by having a datetime column with a default value of getdate(), but is there a trick to do the same for updated.

ie
create table1
( test vachar(1),
created_date datetime default getdate(),
update_date datetime,  
)
and have 'updated_date' column  updated each time an update is made to the table.
I presume I require an update trigger, but how do I populate the updated_date column within the update trigger- any thoughts. Or is there another way.

Please no-one mention timestamp - I know all about that and it doesnt do what it says on the tin
thanks
KD




ASKER CERTIFIED SOLUTION
lahousden

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 10 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 10 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