Home >> FAQs/Tutorials >> SQL Server FAQ
SQL Server FAQ  AND, OR, XOR, and NOT  Bitwise Operations
By: FYIcenter.com
(Continued from previous topic...)
What Are Bitwise Operations?
Bitwise operations are binary operations performed on one or two binary strings.
SQL Server supports 4 bitwise operations:
 & (Bitwise AND)  Performing the single bit Boolean operation "AND" on each bit position.
  (Bitwise OR)  Performing the single bit Boolean operation "OR" on each bit position.
 ^ (Bitwise XOR)  Performing the single bit Boolean operation "XOR" on each bit position.
 ~ (Bitwise NOT)  Performing the single bit Boolean operation "NOT" on each bit position.
The table below shows you how single bit Boolean operations work:
Input 1: 0 0 1 1
Input 2: 0 1 0 1

& (AND) 0 0 0 1
Input 1: 0 0 1 1
Input 2: 0 1 0 1

 (OR) 0 1 1 1
Input 1: 0 0 1 1
Input 2: 0 1 0 1

^ (XOR) 0 1 1 0
Input 1: 0 0 1 1

~ (NOT) 1 1 0 0
 How To Concatenate Two Character Strings Together?
 What Happens When Unicode Strings Concatenate with NonUnicode Strings?
 How To Convert a Unicode Strings to NonUnicode Strings?
 What Are the Character String Functions Supported by SQL Server 2005?
 How To Insert New Line Characters into Strings?
 How To Locate and Take Substrings with CHARINDEX() and SUBSTRING() Functions?
 How To Concatenate Two Binary Strings Together?
 Can Binary Strings Be Used in Arithmetical Operations?
 How To Convert Binary Strings into Integers?
 Can Binary Strings Be Converted into NUMERIC or FLOAT Data Types?
 Can Binary Strings Be Converted into Character Strings?
 Can Binary Strings Be Converted into Unicode Character Strings?
 How To Convert Binary Strings into Hexadecimal Character Strings
 What Are Bitwise Operations?
