4 ms·
I did a similar thing with SQL Server using XML. I created views that would convert the XML value back to the correct SQL data type when querying the audit tabl
by drittich 5y ago
I did a similar thing with SQL Server using XML. I created views that would convert the XML value back to the correct SQL data type when querying the audit table. The view also Unions the audit data with the current data so that you could add the trigger at any time and the view would return the current data (the audit table only stores updates and deletes). One nice addition was saving the current user ID with all audit records, which I was able to get in the trigger by adding it to the db connection using CONTEXT_INFO().
- Pxtl 5y agoMs SQL now has a very good built in feature for temporal tables such that you shouldn't have to use audit tables, it's an out-of-the-box feature. Only problem is that there's no way to delete historical data without DDL operations, which you need if a user demands to exercise their GDPR rights.