• martin.whitton (7/2/2013)


    Danny Ocean (7/1/2013)


    Good question. But i never feel to use "Bitwise AND" (&) in real working scenario. It will good, if anyone come with some real working example. 🙂

    It provides a neat way of sending multiple options as a single integer parameter.

    For example, let's say you have a table called "Locations" with 2 columns, LocationID and Location, containing the following values:

    LocationID Location

    1 London

    2 Dublin

    4 Paris

    8 Berlin

    16 New York

    etc...

    Then you could select any combination of Location values as follows:

    declare @Selection int;

    set @Selection=10; -- (this will select Dublin and Paris, because Dublin's LocationID plus Paris's LocationID equals 10)

    select

    Location

    from

    Locations

    where

    LocationId & @Selection>0;

    Thanks martin 🙂

    Thanks
    Vinay Kumar
    -----------------------------------------------------------------
    Keep Learning - Keep Growing !!!