SQL Flow Field Guide

CERTPRIVATEKEY

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

security context lookup

What changes

Input
security context (login, user, roles, permissions)
Output or change
name, id or boolean
Return type
varbinary

Syntax at a glance

CERTPRIVATEKEY ( cert_ID , ' encryption_password ' [ , ' decryption_password ' ] )

Work example

Inspect private-key material only in a documented certificate maintenance workflow.

Test under the intended execution context. Use GRANT and DENY rather than returned identity text.

Check your work Treat returned bytes as a secret and never print, log, or export them in a training example.

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