SQL Flow Field Guide

~ (Bitwise NOT)

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

operator ~ (Bitwise NOT)

What changes

Input
operand expressions
Output or change
computed value
Return type
int if the input values are int. smallint if the input values are smallint. tinyint if the input values are tinyint. bit if the input values are bit.

Syntax at a glance

~ expression

Work example

A flag field needs ~ (Bitwise NOT) to test or change a specific bit mask.

Use small integer values with one bit set at a time. Compare the mask before and after the expression.

Check your work ~ (Bitwise NOT). The result of ~ (Bitwise NOT) changes only the intended bit and keeps unrelated flags intact.

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