SQL Flow Field Guide

DECRYPTBYASYMKEY

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

cryptographic transform or key lookup

What changes

Input
plaintext or ciphertext and a key, certificate or passphrase
Output or change
ciphertext, plaintext, hash, signature check, or key metadata
Return type
varbinary, with a maximum size of 8,000 bytes.

Syntax at a glance

DecryptByAsymKey (Asym_Key_ID , { 'ciphertext' | @ciphertext } [ , 'Asym_Key_Password' ] )

Work example

Decrypt existing bytes with an asymmetric key whose private key is available.

Use synthetic data in an isolated database. Follow the existing key hierarchy and keep keys and plaintext out of output.

Check your work Check authorization and key availability, and keep plaintext out of logs.

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