DP-800

Implement temporal and ledger tables

This article explains temporal tables, which allow you to retrieve data at any point in time, and ledger tables, which provide tamper-evidence for your data. Both keep a history table with SYSTEM_VERSIONING. It covers why you would use each, how to create them, and how to work with ledger digests.

Phillip Burton  · Published 3 December 2026

Temporal tables

A temporal table is one that allows for the retrieval of data at any point in time. You can use it to:

  • audit all data changes and allow data forensics;
  • get the table as it was at any time in the past;
  • create trends over time;
  • allow for slowly changing dimensions (SCDs) for decision support applications; and
  • restore data if there is a bad data change or an application error.

What a temporal table contains

A temporal table has:

  • two columns with the datetime2 data type, ValidFrom and ValidTo. They record the start and end date/time for that row, and contain the “current value” for the row; and
  • a reference to a history table with a mirrored schema. This records each previous version of each row. You can specify an existing history table or create a default history table.

Creating a temporal table

To create a temporal table, you need the two period columns, a PERIOD FOR SYSTEM_TIME, and SYSTEM_VERSIONING:

CREATE TABLE dbo.Employee (
    …
    [ValidFrom] DATETIME2 GENERATED ALWAYS AS ROW START,
    [ValidTo] DATETIME2 GENERATED ALWAYS AS ROW END,
    PERIOD FOR SYSTEM_TIME (ValidFrom, ValidTo) )
WITH (SYSTEM_VERSIONING = ON (HISTORY_TABLE = dbo.EmployeeHistory));

Ledger tables

Ledger tables provide tamper-evidence capabilities for your data. A ledger table:

  • preserves historical data;
  • allows you to attest to auditors and others that your data has not been tampered with; and
  • protects data from attackers or high-privileged users.

How ledger tables work

Rows modified in a ledger table are cryptographically hashed (like creating a fingerprint).

  • That hash, along with other hashes, creates a blockchain.
  • The latest block is called the database digest. This is the state of all the database ledger tables at that time.

The digests can be stored outside the database in tamper-proof storage – for example:

  • Azure Blob Storage configured with immutability policies;
  • Azure Confidential Ledger; or
  • on-premises Write Once Read Many (WORM) storage devices.

Append-only and updatable ledger tables

There are two types of ledger tables:

TypeAllowsUseful for
Append-only ledger tableOnly insertionsSecurity information and event management (SIEM) applications
Updatable ledger tableInsertions, updates and deletionsSystem of Record (SOR) applications

Updatable ledger tables require a history table, which is automatically created when you create the updatable ledger table.

Ledger databases

You can also create a ledger database, which only contains ledger tables (not regular tables).

  • In Azure SQL Database, when you create an Azure SQL Database, this is available in the Security tab – Ledger. Check Enable for all future tables in this database.
  • The default for all tables in a ledger database is updatable ledger tables.

Creating ledger tables

To create an append-only ledger table, add the following at the end of the table definition:

WITH (LEDGER = ON (APPEND_ONLY = ON));

To create an updatable ledger table, add the following at the end of the table definition:

WITH (SYSTEM_VERSIONING = ON (HISTORY_TABLE = HistoryTable), LEDGER = ON);

Working with ledger data

You can then use the ledger_start_transaction_id and ledger_start_sequence_number columns (and, in the history table, the ledger_end columns), which show what data was inserted or changed at the same time. You can use these for the ledger table and, for updatable ledger tables, the history table.

To verify the digest storage, you can use:

EXEC sp_generate_database_ledger_digest;

Comparing temporal and updatable ledger tables

Both temporal tables and updatable ledger tables keep previous versions of rows in a history table, using SYSTEM_VERSIONING = ON with a HISTORY_TABLE.

Exam tip

Keep the purposes distinct. A temporal table is for retrieving data at any point in time, such as for auditing, trends and restoring data. A ledger table is for tamper-evidence: its rows are cryptographically hashed so that you can attest that the data has not been tampered with.

Continue studying DP-800

This article covers Implement temporal and ledger tables, part of the Design and implement database objects section of the DP-800 study guide.

Related articles

← Back to the DP-800 study guide

Leave a Comment