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

  1. How To Concatenate Two Character Strings Together?
  2. What Happens When Unicode Strings Concatenate with Non-Unicode Strings?
  3. How To Convert a Unicode Strings to Non-Unicode Strings?
  4. What Are the Character String Functions Supported by SQL Server 2005?
  5. How To Insert New Line Characters into Strings?
  6. How To Locate and Take Substrings with CHARINDEX() and SUBSTRING() Functions?
  7. How To Concatenate Two Binary Strings Together?
  8. Can Binary Strings Be Used in Arithmetical Operations?
  9. How To Convert Binary Strings into Integers?
  10. Can Binary Strings Be Converted into NUMERIC or FLOAT Data Types?
  11. Can Binary Strings Be Converted into Character Strings?
  12. Can Binary Strings Be Converted into Unicode Character Strings?
  13. How To Convert Binary Strings into Hexadecimal Character Strings
  14. What Are Bitwise Operations?

Related Articles:

More...


Other Tutorials/FAQs:

More...


Related Resources:

More...


Selected Jobs:

More...