SQL Flow Field Guide

CLOSE SYMMETRIC KEY

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

closes a symmetric key in the session

What changes

Input
none
Output or change
session key state

Syntax at a glance

CLOSE { SYMMETRIC KEY key_name | ALL SYMMETRIC KEYS }

Work example

A session has finished decrypting or encrypting values with a symmetric key.

Check the session's remaining statements and close the named key after its last use.

Check your work The key is closed before the session handles unrelated work.

Open Microsoft Learn for full syntax, permissions, and details for your version.