Επεξεργασία

Κοινή χρήση μέσω


Configure a ledger database

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

This article provides information on configuring a ledger database using the Azure portal, T-SQL, PowerShell, or the Azure CLI for Azure SQL Database. For information on creating a ledger database in SQL Server 2022 (16.x) or Azure SQL Managed Instance, use the switch at the top of this page.

Prerequisites

Enable ledger database

Note

Enabling the ledger functionality at the database level will make all tables in this database updatable ledger tables. This option cannot be changed after the database is created. Creating a table with the option LEDGER = OFF will throw an error message.

  1. Open the Azure portal and create an Azure SQL Database .

  2. On the Security tab, select Configure ledger.

    Screenshot that shows the Azure portal with the Security Ledger tab selected.

  3. On the Configure ledger pane, select Enable for all future tables in this database.

    Screenshot that shows the selection for enabling a ledger database.

  4. Select Apply to save this setting.

This article provides information on configuring a ledger database using T-SQL, PowerShell, or the Azure CLI for Azure SQL Managed Instance. For information on creating a ledger database in SQL Server 2022 (16.x) or Azure SQL Database, use the switch at the top of this page.

Prerequisites

  • Have an active Azure subscription. If you don't have one, create a free account.
  • An Azure SQL Managed Instance.

Enable ledger database

Note

Enabling the ledger functionality at the database level will make all tables in this database updatable ledger tables. This option cannot be changed after the database is created. Creating a table with the option LEDGER = OFF will throw an error message.

Enable ledger database using T-SQL

  1. Sign into your managed instance using SQL Server Management Studio (SSMS), Azure Data Studio or SQL Server Data Tools (SSDT).

  2. Create a ledger database using the following T-SQL statement:

    CREATE DATABASE MyLedgerDB  WITH LEDGER = ON;
    

For more information, see CREATE DATABASE (Transact-SQL).

This article provides information on creating a ledger database by using T-SQL in SQL Server 2022 (16.x). For information on creating a ledger database in Azure SQL Database or Azure SQL Managed Instance, use the switch at the top of this page.

Prerequisites

Create a ledger database using T-SQL

  1. Sign into your SQL Server 2022 (16.x) instance using SSMS, Azure Data Studio or SSDT.

  2. Create a ledger database using the following T-SQL statement:

    CREATE DATABASE MyLedgerDB  WITH LEDGER = ON;
    

For more information, see CREATE DATABASE (Transact-SQL).