Tsql base bitwise operator value Inversion

Source: Internet
Author: User
Tags bitwise operators
Bitwise operators

Bitwise operators perform bitwise operations between two expressions. These two expressions can be any two integer data types. Symbols of bitwise operators and their definitions are as follows:4.3.

Table4.3Bitwise operators

Operator

IncludingYi

& ( by bit and)

bitwise AND ( two operands )

| ( by bit or)

bitwise OR ( two operands )

^ ( bitwise mutex or)

bitwise OR ( two operands )

~ (By bitNot)

Bitwise Inversion(One operand)

 

Bitwise operators can be any data type in integer or binary string data types.(HoweverImageExcept for Data Types)In addition, the two operands cannot be a data type of the binary string data type at the same time.

Case: reverse the following sex field. Another method is case when... end.

 
Declare @ TB table (sex bit, num2 INT) insert into @ TB Select Insert into @ TB select Insert into @ TB select sex, '~ Sex inverse '= ~ Sex, 'sex ^ '= sex ^ 1, num2 from @ TB

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.