devxlogo

Boolean Operations Between Bit Variables in SQL

Boolean Operations Between Bit Variables in SQL

Use Bitwise Operators in T-SQL to do AND/OR/XOR (&/|/^) between two or more bit/integer variables.

You can use z = x and y in VB where x,y,z is Boolean, in T-SQL:

SET @z =@x & @y

Or swap two Integer variables:

DECLARE @X int, @y intSET @x = 5SET @y = 6SELECT @x as X, @y as YSET @x = @x ^ @ySET @y = @y ^ @xSET @x = @x ^ @ySELECT @x as X, @y as Y

devx-admin

Share the Post: