SQL Flow Field Guide

CLOSE MASTER KEY

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

closes the database master key in the session

What changes

Input
none
Output or change
session key state

Syntax at a glance

CLOSE MASTER KEY

Work example

A session has finished work that required its database master key.

Trace every later statement in the session and close the key after its final protected operation.

Check your work The session no longer needs the open key and later work opens it only through the approved path.

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