sys.sp_generate_database_ledger_digest (Transact-SQL)

Applies to: YesAzure SQL Database

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 will close the block and generate the hash. Future transactions will then be assigned to the next block.

For more information on database ledger, see Azure SQL Database ledger

Topic link icon Transact-SQL Syntax Conventions


EXEC sys.sp_generate_database_ledger_digest

Return code values

0 (success) or 1 (failure).

Result sets

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.
hash – a hexadecimal string representing a SHA-256 hash of the last row in sys.database_ledger.
last_transaction_commit_time - same as commit_time from the last row in sys.database_ledger in the ISO 8601 format.
digest_time – the time when the digest was generated in the ISO 8601 format.

Example 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"


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

See also