Chapter 9. Temporal tables

When you modify data in tables, normally you lose any trace of the premodified state of the rows. You can access only the current state. What if you need to be able to access historical states of the data? Perhaps you need these states for auditing, point-in-time analysis, comparing current states with older states, slowly changing dimensions (details of which you can find in the Wikipedia article at https://en.wikipedia.org/wiki/Slowly_changing_dimension), restoring an older state of rows because of accidental deletion or updating, and so on. You could roll your own customized solution based on triggers. Better yet, starting with Microsoft SQL Server 2016, you can use a built-in feature called system-versioned temporal ...

Get T-SQL Fundamentals, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.