In our Senior DBA Class, one of the exercises involves figuring out changes to a table after an Always On Availability Group failover. In every class, several students always say the same thing: “I really wish I had a LastUpdatedDate column on all of my tables that just updated automatically.”
Whaddya know – Adam Machanic filed Connect #3105516 for that exact thing. He writes:
“It is extremely common for databases to contain columns like “UpdatedDate,” “UpdatedBy,” etc. These columns work based on a trust model: As a database designer, I must trust that all of my downstream consumers will follow the intended rules, remembering to update the columns every single time any transaction occurs. And of course I have to trust that they’ll put in the correct values. The only alternative to trust is to put ugly and potentially slow triggers in place to make sure everything happened the right way.
This situation needs to change, and this is especially prevalent now, thanks to SQL Server 2016 temporal tables. Many customers I’ve spoken to regarding these tables would really like to be able to audit who made the change. Some of them would like to audit which host name the change came from. And so on and so forth. The bottom line is that we need a flexible solution to allow users to declaratively model these situations.”
I love it! Head over there and give it an upvote.