Skip to content

Latest commit

 

History

History
75 lines (59 loc) · 2.96 KB

File metadata and controls

75 lines (59 loc) · 2.96 KB
title CLOSE SYMMETRIC KEY (Transact-SQL)
description CLOSE SYMMETRIC 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 SYMMETRIC KEY
CLOSE_SYMMETRIC_KEY_TSQL
helpviewer_keywords
closing symmetric keys
encryption [SQL Server], symmetric keys
symmetric keys [SQL Server], closing
CLOSE SYMMETRIC KEY statement
cryptography [SQL Server], symmetric keys
dev_langs
TSQL
monikerRange =azuresqldb-current || =azuresqldb-mi-current || >=sql-server-2016 || >=sql-server-linux-2017 || =azure-sqldw-latest || =fabric-sqldb

CLOSE SYMMETRIC KEY (Transact-SQL)

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

Closes a symmetric key, or closes all symmetric keys open in the current session.

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

Syntax

CLOSE { SYMMETRIC KEY key_name | ALL SYMMETRIC KEYS }  

Arguments

Key_name
Is the name of the symmetric key to be closed.

Remarks

Open symmetric keys are bound to the session not to the security context. An open key will continue to be available until it is either explicitly closed or the session is terminated. CLOSE ALL SYMMETRIC KEYS will close any database master key that was opened in the current session by using the OPEN MASTER KEY statement. Information about open keys is visible in the sys.openkeys (Transact-SQL) catalog view.

Permissions

No explicit permission is required to close a symmetric key.

Examples

A. Closing a symmetric key

The following example closes the symmetric key ShippingSymKey04.

CLOSE SYMMETRIC KEY ShippingSymKey04;  
GO  

B. Closing all symmetric keys

The following example closes all symmetric keys that are open in the current session, and also the explicitly opened database master key.

CLOSE ALL SYMMETRIC KEYS;  
GO  

See Also

CREATE SYMMETRIC KEY (Transact-SQL)
ALTER SYMMETRIC KEY (Transact-SQL)
OPEN SYMMETRIC KEY (Transact-SQL)
DROP SYMMETRIC KEY (Transact-SQL)