title: "CLOSE MASTER KEY (Transact-SQL) | Microsoft Docs" ms.custom: "" ms.date: "05/15/2017" ms.prod: "sql" ms.prod_service: "database-engine, sql-database, sql-data-warehouse, pdw" ms.service: "" ms.component: "t-sql|statements" ms.reviewer: "" ms.suite: "sql" ms.technology:
- "database-engine" ms.tgt_pltfrm: "" ms.topic: "language-reference" f1_keywords:
- "CLOSE MASTER KEY"
- "CLOSE_MASTER_KEY_TSQL" dev_langs:
- "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" ms.assetid: bb04ef7a-9f3a-437e-a6f9-ba0204082cb9 caps.latest.revision: 30 author: "edmacauley" ms.author: "edmaca" manager: "craigg" ms.workload: "Inactive" monikerRange: ">= aps-pdw-2016 || = azuresqldb-current || = azure-sqldw-latest || >= sql-server-2016 || = sqlallproducts-allversions"
[!INCLUDEtsql-appliesto-ss2008-all-md]
Closes the master key of the current database.
Transact-SQL Syntax Conventions
CLOSE MASTER KEY
Takes no arguments.
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.
No permissions are required.
USE AdventureWorks2012;
CLOSE MASTER KEY;
GO
USE master;
OPEN MASTER KEY DECRYPTION BY PASSWORD = '43987hkhj4325tsku7';
GO
CLOSE MASTER KEY;
GO
CREATE MASTER KEY (Transact-SQL)
OPEN MASTER KEY (Transact-SQL)
Encryption Hierarchy