sys.sp_generate_database_ledger_digest (Transact-SQL)

Applies to: SQL Server 2022 (16.x) Azure SQL Database Azure SQL Managed Instance

Generates the ledger digest, which is the hash of the last block in sys.database_ledger_blocks. If the last block is open (transactions have been grouped to the block but no final block hash has been generated), this stored procedure closes the block and generates the hash. Future transactions will then be assigned to the next block.

Transact-SQL syntax conventions

Syntax

sys.sp_generate_database_ledger_digest

Arguments

None.

Return code values

0 (success) or 1 (failure).

Result set

Column name Description
latest_digest A JSON document containing the following data:

database_name - the name of the database.
block_id – same as block_id from the last row in sys.database_ledger_blocks.
hash – a hexadecimal string representing the SHA-256 hash of the last row in sys.database_ledger_blocks.
last_transaction_commit_time - same as commit_time from the last row in sys.database_ledger_blocks in the ISO 8601 format.
digest_time – the time when the digest was generated in the ISO 8601 format.

Example of the JSON

{
    "database_name": "contoso",
    "block_id": 0,
    "hash": "0x6D7D609DE43DDBF84A0346463D6F93CA979846CD5609E02E4FFC96338FC64DD5",
    "last_transaction_commit_time": "2020-10-06T16:50:55.1066667",
    "digest_time": "2020-10-07T01:13:23.3601279"
}

Permissions

Users with the public role are allowed to execute this stored procedure.