SQL Flow Field Guide

COMPRESS

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

system function

What changes

Input
arguments or engine/session state
Output or change
value
Return type
varbinary(max), representing the compressed content of the input.

Syntax at a glance

COMPRESS ( expression )

Work example

Compress a binary or text expression for an existing storage format.

Read state in the intended scope and immediately after the statement it describes. Treat host values as untrusted.

Check your work Record the source type and verify the payload can be decompressed.

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