RE: Bitwise Comparison in WHERE Clause

From: Kevin Yu [MSFT] (v-kevy_at_online.microsoft.com)
Date: 04/24/04


Date: Sat, 24 Apr 2004 03:40:23 GMT

Hi Michael,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to know how to do bitwise
comparison in the WHERE clause of a SELECT statement. If there is any
misunderstanding, please feel free to let me know.

As far as I know, bitwise operators are provided by T-SQL. Bitwise
operators are used on int, smallint, or tinyint data. The ~ (Bitwise NOT)
operator can also use bit data. All bitwise operators perform an operation
on the one or more specified integer values as translated to binary
expressions within Transact-SQL statements. To check bitwise operations,
you can convert or calculate decimal values. Here are the bitwise operators
available in T-SQL.

& (Bitwise AND)
~ (Bitwise NOT)
| (Bitwise OR)
^ (Bitwise Exclusive OR)

For more information, please check the following link. Examples are include
when you click on each operator.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/acdata/ac_8
_qd_02_55rn.asp

HTH. If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."



Relevant Pages

  • Re: Check for multiple file attributes
    ... are bitwise operators, meant to be used on integral types for bit ... Nicholas Paldino ... >> Yes, the FileAttributes enumeration is a bitwise mask, so you would>> compare in that manner. ... However, you do have to make sure the result is>> not zero, because C# does not assume that a non zero integer value>> evaluates to true, rather, you have to use a boolean value. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: program logic based on endianness
    ... The logic of shifting and action based on the result, ... assumes that the system is big-endian. ... I wanted to know if the above holds true for bitwise and and ... the bitwise operators -- work on the values of their ...
    (comp.unix.programmer)
  • Re: Bitwise OR and AND without bitwise operators....
    ... but how can I do the bitwise AND? ... Notice you can re-use some results if you work lsb to msb. ... So just iterate bitwise yourself and add 2^k to your result when the ...
    (sci.math)
  • Bitwise OR and AND without bitwise operators....
    ... I am working in a programming language which does not support ... but how can I do the bitwise AND? ...
    (sci.math)

Loading