In SQL there are some build in bitwise operators like you can see in the following table
But what sometimes really is missing is NAND and XNOR. But you can easily build them by your own.
Those two missing NAND and XNOR can be build as follows:
DECLARE @a bit = 0; DECLARE @b bit = 1; --NAND SELECT @a & @b ^ 1; --XNOR SELECT @a ^ @b ^ 1
In order to make it a bit easier you can create two User Defined Functions.
--NAND CREATE FUNCTION NAND (@a bit, @b bit) RETURNS bit AS BEGIN RETURN @a & @b ^ 1 END --XNOR CREATE FUNCTION XNOR (@a bit, @b bit) RETURNS bit AS BEGIN RETURN @a ^ @b ^ 1 END