Ledger Tables for Tamper Evidence
This lesson explains how ledger tables make data tamper-evident with hashes and external digests, and how they differ from temporal tables and auditing.
Learning outcomes
After completing this lesson, you will be able to:
- Explain how database digests and verification detect tampering.
- Distinguish between updatable and append-only ledger tables.
- Choose between ledger, temporal tables and auditing for a requirement.
How ledger works
The ledger feature computes a SHA-256 hash of every row version changed by a transaction and links transactions into blocks, each containing the hash of the previous block, like a blockchain. Periodically, the root hash of the database ledger, the database digest, is exported to trusted storage such as Azure immutable blob storage or Azure Confidential Ledger. Because the digests are outside the database, an administrator who changes rows directly in the data files, or rewrites history, cannot recompute digests that are already stored.
sys.sp_verify_database_ledger (or sp_verify_database_ledger_from_digest_storage) recomputes the hashes and compares them with the stored digests, reporting any tampering. Ledger provides tamper evidence, not tamper prevention: it proves whether data was altered but does not stop someone with permissions from changing it.
The following diagram shows the hash chain and the exported digest.

Updatable and append-only ledger tables
An updatable ledger table allows inserts, updates and deletes; it has a history table and a ledger view that shows every operation with its transaction. An append-only ledger table allows only inserts, which suits logs, sensor readings and financial postings that must never change. A ledger database makes every table a ledger table automatically. Ledger tables cannot be converted back to ordinary tables, and dropped ledger tables are kept as dropped ledger tables.
CREATE TABLE Finance.Payments
(
PaymentID int NOT NULL PRIMARY KEY,
Amount decimal(12,2) NOT NULL,
PaidUtc datetime2 NOT NULL
)
WITH (SYSTEM_VERSIONING = ON, LEDGER = ON); -- updatable
CREATE TABLE Finance.AuditEvents
(
EventID bigint IDENTITY PRIMARY KEY,
Detail nvarchar(400) NOT NULL
)
WITH (LEDGER = ON (APPEND_ONLY = ON)); -- append-onlyUpdatable or append-only?
Ledger compared with temporal tables and auditing
Temporal tables keep history for querying, auditing records who did what, and ledger proves integrity. The following comparison helps choose between them.
Temporal, ledger or auditing?
Proving payment records were not altered
An auditor requires proof that payment records in an Azure SQL database have not been modified by anyone, including database administrators, since they were written. Payments are never updated after insertion. Which design meets the requirement with the least effort?
Create the payments table as an append-only ledger table with automatic digest storage enabled, and run sp_verify_database_ledger when the auditor asks. Append-only matches the insert-only workload and blocks updates and deletes through T-SQL, and the external digests make direct tampering detectable. A temporal table records history but administrators can disable versioning and change it, and auditing records actions without proving the data is intact.
Does a ledger table stop an administrator from updating rows through T-SQL?
Show answer
Not for an updatable ledger table: it records and proves changes rather than preventing them. Only append-only ledger tables block updates and deletes.
Exam Tips
Remember for the exam
- Tamper evidence, even against administrators: ledger tables with external digest storage.
- Insert-only data: append-only ledger table; updates allowed: updatable ledger table.
- Verify integrity: sp_verify_database_ledger.
- Ledger detects tampering; it does not prevent authorized changes.