SQL Flow Field Guide

CRYPT_GEN_RANDOM

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

cryptographic random generator

What changes

Input
length, optional seed
Output or change
random bytes

Syntax at a glance

CRYPT_GEN_RANDOM ( length [ , seed ] )

Work example

Generate random bytes for a reviewed cryptographic workflow with a defined use.

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

Check your work Choose the documented byte length and never treat random output as a password hash or key lifecycle.

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