You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: "Copies data from the source table to the target table after verifying that their schema is identical in terms of number of columns, column names and their data types."
[!INCLUDE [SQL Server 2022 Azure SQL Database](../../includes/applies-to-version/sqlserver2022-asdb.md)]
18
18
19
-
Copies data from the source table to the target table after verifying that their schema is identical in terms of number of columns, column names and their data types. `TRANSACTION ID`, `SEQUENCE NUMBER`, and `GENERATED ALWAYS` columns are ignored since they're system generated and this allows copying data from a regular table to a ledger table and vice versa. Indexes between the tables can be different but the target table can only be a Heap or have a clustered index. The data is copied in batches in individual transactions. If the operation fails, the target table will be partially populated.
19
+
Copies data from the source table to the target table after verifying that their schema is identical in terms of number of columns, column names and their data types. `TRANSACTION ID`, `SEQUENCE NUMBER`, and `GENERATED ALWAYS` columns are ignored since they're system generated and this allows copying data from a regular table to a ledger table and vice versa. Indexes between the tables can be different but the target table can only be a heap or have a clustered index. The data is copied in batches in individual transactions. If the operation fails, the target table is partially populated.
20
+
21
+
For more information on database ledger, see [Ledger](/azure/azure-sql/database/ledger-overview).
20
22
21
-
For more information on database ledger, see [Ledger](/azure/azure-sql/database/ledger-overview)
The name of the table to be used as the target of the data copy.
38
40
39
41
## Return code values
@@ -46,9 +48,9 @@ None.
46
48
47
49
## Permissions
48
50
49
-
This operation requires **SELECT** on the source table, **INSERT** in the target table, and **ALTER** on the target table if there are Foreign Key or Check constraints that will be disabled or an Identity column that will be adjusted.
51
+
This operation requires **SELECT** on the source table, **INSERT** in the target table, and **ALTER** on the target table if there are foreign key or check constraints that will be disabled, or an identity column that will be adjusted.
50
52
51
-
## See also
53
+
## Next steps
52
54
53
55
-[Ledger considerations and limitations](../security/ledger/ledger-limits.md)
[!INCLUDE [SQL Server 2022 Azure SQL Database](../../includes/applies-to-version/sqlserver2022-asdb.md)]
18
18
19
-
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.
19
+
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.
|**latest_digest**|A JSON document containing the following data:<br/><br/>`database_name` - the name of the database. <br/>`block_id` – same as block_id from the last row in sys.database_ledger_blocks.<br/>`hash` – a hexadecimal string representing a SHA-256 hash of the last row in sys.database_ledger_blocks.<br/>`last_transaction_commit_time` - same as commit_time from the last row in sys.database_ledger_blocks in the ISO 8601 format.<br/>`digest_time` – the time when the digest was generated in the ISO 8601 format.
39
+
|Column name|Description|
40
+
|---|---|
41
+
|**latest_digest**|A JSON document containing the following data:<br/><br/>`database_name` - the name of the database. <br/>`block_id` – same as block_id from the last row in `sys.database_ledger_blocks`.<br/>`hash` – a hexadecimal string representing the SHA-256 hash of the last row in `sys.database_ledger_blocks`.<br/>`last_transaction_commit_time` - same as commit_time from the last row in `sys.database_ledger_blocks` in the ISO 8601 format.<br/>`digest_time` – the time when the digest was generated in the ISO 8601 format.
Copy file name to clipboardExpand all lines: docs/relational-databases/system-stored-procedures/sys-sp-verify-database-ledger-from-digest-storage-transact-sql.md
Verifies the database ledger and the table ledgers using digests at the specified external digest storage locations.
20
20
21
-
This stored procedure implements the same ledger verification algorithm as [sp_verify_database_ledger](sys-sp-verify-database-ledger-transact-sql.md). A caller is expected to provider a JSON, which contains the paths pointing to digest storage locations, such as [Azure Blob storage](/azure/storage/blobs/storage-blobs-introduction) containers.
21
+
This stored procedure implements the same ledger verification algorithm as [sp_verify_database_ledger](sys-sp-verify-database-ledger-transact-sql.md). A caller is expected to provide a JSON document that contains the paths pointing to digest storage locations, such as [Azure Blob storage](/azure/storage/blobs/storage-blobs-introduction) containers.
22
+
23
+
For more information on database ledger, see [Ledger](/azure/azure-sql/database/ledger-overview).
22
24
23
-
For more information on database ledger, see [Ledger](/azure/azure-sql/database/ledger-overview)
|**path**|**string**|The location of storage digests. For example, a path for a container in Azure Blob Storage.|
42
-
|**last_digest_block_id**|**int**|The block ID for the last digest uploaded.|
43
-
|**is_current**|**boolean**|Indicates whether this is the current path or a path used in the past.|
39
+
| Column name | JSON data type | Description |
40
+
| --- | --- | --- |
41
+
|**path**|**string**| The location of storage digests. For example, a path for a container in Azure Blob Storage. |
42
+
|**last_digest_block_id**|**int**| The block ID for the last digest uploaded. |
43
+
|**is_current**|**boolean**| Indicates whether this is the current path or a path used in the past. |
44
+
45
+
#### [ @table_name = ] '*table_name*'
44
46
45
-
[ @table_name = ] '*table_name*'
46
-
47
-
The name of the ledger table you want to verify. This is an optional argument, if this is not specified the whole database ledger and the ledger tables are verified.
47
+
The name of the ledger table you want to verify. This argument is optional. If this isn't specified, the whole database ledger and the ledger tables are verified.
[!INCLUDE [SQL Server 2022 Azure SQL Database](../../includes/applies-to-version/sqlserver2022-asdb.md)]
18
18
19
-
Verifies the database ledger and the table ledgers. For each row in the sys.database_ledger view, the stored procedure:
19
+
Verifies the database ledger and the table ledgers. For each row in the `sys.database_ledger` view, the stored procedure:
20
20
21
21
1. Recomputes a value stored in the previous_block_hash column of the row.
22
22
1. Checks if the recomputed value matches the value currently stored in the previous_block_hash column.
23
23
1. If the specified list of digests contains a digest for the ledger block the row represents, it verifies the recomputed value matches the hash in the digest.
24
-
1. If a ledger table name is specified using the `table_name` argument, the stored procedure verifies a table hash for the specified table, if it exists in the table_hashes column of sys.database_ledger. Otherwise, it verifies all table hashes existing in the table_hashes column of sys.database_ledger, except table hashes for non-existing (dropped) tables. When verifying a table hash for a ledger table, the stored procedure:
25
-
1. Scans the history table of the ledger table to recompute the table hash, which is a hash of all rows updated by the transaction represented by the current row in sys.database_ledger in the ledger table.
26
-
1. Checks if the recomputed table hash matches the value stored in the table_hashes column of sys.database_ledger for the given ledger table.
24
+
1. If a ledger table name is specified using the `table_name` argument, the stored procedure verifies a table hash for the specified table, if it exists in the table_hashes column of `sys.database_ledger`. Otherwise, it verifies all table hashes existing in the table_hashes column of `sys.database_ledger`, except table hashes for non-existing (dropped) tables. When verifying a table hash for a ledger table, the stored procedure:
25
+
1. Scans the history table of the ledger table to recompute the table hash, which is a hash of all rows updated by the transaction represented by the current row in `sys.database_ledger` in the ledger table.
26
+
1. Checks if the recomputed table hash matches the value stored in the table_hashes column of `sys.database_ledger` for the given ledger table.
27
+
28
+
In addition, the stored procedure verifies all nonclustered indexes are consistent with the specified ledger table. If no ledger table is specified, it verifies all nonclustered indexes for each existing ledger table referenced in the table_hashes column in any row of `sys.database_ledger`.
27
29
28
-
In addition, the stored procedure verifies all non-clustered indexes are consistent with the specified ledger table. If no ledger table is specified, it verifies all non-clustered indexes for each existing ledger table referenced in the table_hashes column in any row of sys.database_ledger.
30
+
For more information on database ledger, see [Ledger](/azure/azure-sql/database/ledger-overview).
29
31
30
-
For more information on database ledger, see [Ledger](/azure/azure-sql/database/ledger-overview)
A JSON document containing a list of transaction digests, each of which has been obtained by querying the sys.database_ledger_latest_digest view. The JSON document must contain at least one digest.
44
+
A JSON document containing a list of transaction digests, each of which has been obtained by querying the `sys.database_ledger_latest_digest` view. The JSON document must contain at least one digest.
45
45
46
-
[ @table_name = ] '*table_name*'
46
+
#### [ @table_name = ] '*table_name*'
47
47
48
48
The name of the table that you want to verify.
49
49
@@ -53,13 +53,13 @@ The name of the table that you want to verify.
53
53
54
54
## Result sets
55
55
56
-
1 row with 1 column called: last_verified_block_id
56
+
One row, with one column called`last_verified_block_id`.
0 commit comments