Testing numeric values with bitwise operators. : bitwise operators « Data Types « SQL Server / T-SQL Tutorial






6>
7>     CREATE PROC pr_bitwise
8>     AS
9>     DECLARE @chvHold INTEGER
10>     SELECT @chvHold = 2
11>     IF ( @chvHold & 1) = 1
12>          BEGIN
13>             PRINT 'One Selected'
14>             RETURN
15>          END
16>     IF ( @chvHold & 2) = 2
17>          BEGIN
18>             PRINT 'Two Selected'
19>             RETURN
20>          END
21>     IF ( @chvHold & 3) = 3
22>          BEGIN
23>             PRINT 'Three Selected'
24>             RETURN
25>          END
26>     IF ( @chvHold & 4) = 4
27>          BEGIN
28>             PRINT 'Four Selected'
29>             RETURN
30>          END
31>     GO
1>
2>     EXEC pr_bitwise
3>     GO
Two Selected
1>
2>     DROP PROC pr_bitwise
3>     GO
1>








5.3.bitwise operators
5.3.1.Selecting data using bitwise operators.
5.3.2.Testing numeric values with bitwise operators.
5.3.3.Bitwise NOT (~) Validity Table
5.3.4.Legal Bitwise Operation
5.3.5.Retrieving Index Properties by Using the Bitwise AND (&) Operator
5.3.6.Bitwise AND (&)
5.3.7.Bitwise OR (|)
5.3.8.Exclusive Or (^)
5.3.9.Bitwise NOT (~)
5.3.10.The bitwise_not() Scalar Function
5.3.11.The bitwise_and() Scalar Function
5.3.12.The bitwise_or() Scalar Function
5.3.13.The bitwise_xor() Scalar Function