~ (Bitwise NOT) (SQL Server Compact Edition)

Performs a bitwise logical NOT operation for one given integer value as translated to binary expressions within SQL statements.

Syntax

~ expression

Arguments

  • expression
    Any valid expression in Microsoft SQL Server 2005 Compact Edition of any of the data types of the integer data type category, or of the binary or varbinary data type. The expressionis an integer that is treated and transformed into a binary number for the bitwise operation.

Result Types

Returns an int if the input values are int, a smallint if the input values are smallint, a tinyint if the input values are tinyint, or a bit if the input values are bit.

Example

The following example performs the bitwise NOT operation between two integer columns.

CREATE TABLE bitwise (A int NOT NULL, B int NOT NULL)
INSERT bitwise VALUES (170, 75)
SELECT ~ A, ~ B FROM bitwise
--Returns -171 and -76