status&64=64 ???

  • Hi,

     

    pls can anyone explain me what does "status&64=64" mean ?

    i cant find any explaination of it in BOL...

     

    tks

  • It is a BIT field test.

    • BIT 1 = 1
    • BIT 2 = 2
    • BIT 3 = 4
    • BIT 4 = 8
    • BIT 5 = 16
    • BIT 6 = 32
    • BIT 7 = 64

    The & means BIT AND.  BIT AND means if both bits are set then return a value.

    BIT OR means if either BIT is set then return a value.

    See my article for further details on bitwise operators  http://www.sqlservercentral.com/columnists/dpoole/usingbitstostoredata_printversion.asp

     

  • It's bitwise operation.

    & for bitwise AND

    64 = binary 1000000

    status&64=64 is checking if status column has that bit(s) been set.

    Refer BOL for detail info on bitwise operators.

  • It's a bitwise mask!! bitwise mask is used in trigger.

    EXAMPLE:

    You have a table of 5 columns A, B, C, D and E

    Check whether columns 2, 3 or 4 has been updated.

    A) To check if all columns 2, 3, and 4 are updated, use = 14 in place of >0 (below).

    - IF (COLUMNS_UPDATED() & 14) > 0

    B) Use to see if all of columns 2, 3, and 4 are updated.

    - IF (COLUMNS_UPDATED() & 14) = 14

    COLS  A B C D E

    BIT   0 1 1 1 0

    Read this from right 1110(Binary) = 14 (decimal)

    If you have problem tell me!!

    Frank!!

     

     

  • hi everybody,

    tks for ur kindness & explainations.

     

    good day

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply