Rohit Raghuvansi
Rohit Raghuvansi

Reputation: 2864

What is the use of "&" operator in SQL SERVER

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

Upvotes: 12

Views: 46972

Answers (3)

Michael Pakhantsov
Michael Pakhantsov

Reputation: 25390

& is bit AND operation:

  • & Bitwise AND

  • | Bitwise OR

  • ^ Bitwise exclusive OR

  • ~ Bitwise NOT

Upvotes: 16

Simmo
Simmo

Reputation: 3131

It's a bitwise operator - AND

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

Upvotes: 0

SQLMenace
SQLMenace

Reputation: 135111

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

Upvotes: 0

Related Questions