views:

65

answers:

3

What is the use of & operator in the code specified below. IS there any benefit of using & instead of "AND". Please elaborate.

CASE ( C.[Status] & F.[Status] & D.[Status] & DWT.[Status] & P.[Status] )
    WHEN 1
        THEN CASE ( C.IsDeleted & F.IsDeleted & D.IsDeleted & P.IsDeleted )
        WHEN 0 THEN NULL
        ELSE 7
        END
    ELSE 6
END
+5  A: 

& is bit AND operation:

  • & Bitwise AND

  • | Bitwise OR

  • ^ Bitwise exclusive OR

  • ~ Bitwise NOT

Michael Pakhantsov
what is its use as compared to logical AND ?
Rohit
@Rohit, Hope this article "Using SQL Server Bitwise operators to store multiple values in one column" http://www.mssqltips.com/tip.asp?tip=121 explain you more
Michael Pakhantsov
@Michael Pakhanstov: Did you miss the last '8' in the link?http://www.mssqltips.com/tip.asp?tip=1218
Geert Immerzeel
@Geert Immerzeel Thanks for corrections, yes I meant tip=1218
Michael Pakhantsov
A: 

Bitwise AND operation, take a look at & (Bitwise AND) (Transact-SQL) in Books On Line

SQLMenace
A: 

It's a bitwise operator - AND

http://msdn.microsoft.com/en-us/library/ms176122.aspx

Simmo