What does the & symbol mean in this TSQL query?

I worked on some reports and recently found a little guide for the system I was referring to. Part of the proposed syntax is as follows:

... "WHERE [FIELD] & [VALUE] = [VALUE]"

ie: ... "WHERE flags & 16 = 16"

I'm just wondering what the syntax is ... I get something like WHERE flags = 16, but not part of '& 16 = 16'. Any clarifications?

The article refers to: http://rightfaxapi.com/advanced-sql-for-manipulating-faxes/

Thanks Wes

+3
source share
2 answers

&performs bitwise "and". Thus, it is “1” only when both bits are equal to 1. General logic checks that all bits in are valueset to field.

, value:

0000 0101

,

1111 1111

&:

0000 0101

(1 , 1.)

, value. , .

, field:

0001 1110

&:

0000 0100

value, .

+5

& . 16 (0x0010, 0000 0000 0001 0000). Reslt AND 0 ( ), ( ARE ). , where A&16 = 16 , 5 , .

:

  • 48 & 16 = 16 :

        48 (binary: 0000 0000 0011 0000)
    AND 16 (binary: 0000 0000 0001 0000)
        -- -----------------------------
        16 (binary: 0000 0000 0001 0000)
    
  • 33 & 16 = 16 :

        33 (binary: 0000 0000 0010 0001)
    AND 16 (binary: 0000 0000 0001 0000)
        -- -----------------------------
         0 (binary: 0000 0000 0000 0000)
    

!

+2

All Articles