Skip to content

Latest commit

 

History

History
74 lines (58 loc) · 2.32 KB

File metadata and controls

74 lines (58 loc) · 2.32 KB
title CLOSE MASTER KEY (Transact-SQL)
description CLOSE MASTER KEY (Transact-SQL)
author VanMSFT
ms.author vanto
ms.date 05/15/2017
ms.service sql
ms.subservice t-sql
ms.topic reference
ms.custom
ignite-2025
f1_keywords
CLOSE MASTER KEY
CLOSE_MASTER_KEY_TSQL
helpviewer_keywords
encryption [SQL Server], Database Master Key
CLOSE MASTER KEY statement
database master key [SQL Server], closing
cryptography [SQL Server], Database Master Key
closing Database Master Keys
dev_langs
TSQL
monikerRange >=aps-pdw-2016 || =azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric-sqldb

CLOSE MASTER KEY (Transact-SQL)

[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance Azure Synapse Analytics PDW FabricSQLDB]

Closes the master key of the current database.

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

CLOSE MASTER KEY  

Arguments

Takes no arguments.

Remarks

This statement reverses the operation performed by OPEN MASTER KEY. CLOSE MASTER KEY only succeeds when the database master key was opened in the current session by using the OPEN MASTER KEY statement.

Permissions

No permissions are required.

Examples

USE AdventureWorks2022;  
CLOSE MASTER KEY;  
GO  

Examples: [!INCLUDEssazuresynapse-md] and [!INCLUDEssPDW]

USE master;  
OPEN MASTER KEY DECRYPTION BY PASSWORD = '43987hkhj4325tsku7';  
GO   
CLOSE MASTER KEY;  
GO  

See Also

CREATE MASTER KEY (Transact-SQL)
OPEN MASTER KEY (Transact-SQL)
Encryption Hierarchy