SQL SERVER中“&”运算符有什么用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3458345/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 07:10:35  来源:igfitidea点击:

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

sqlsql-servertsql

提问by Rohit Raghuvansi

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

下面指定的代码中 & 运算符的用途是什么。使用 & 而不是“AND”有什么好处。请详细说明。

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

回答by Michael Pakhantsov

&is bit AND operation:

&是位与运算:

  • &Bitwise AND

  • |Bitwise OR

  • ^Bitwise exclusive OR

  • ~Bitwise NOT

  • &按位与

  • |按位或

  • ^按位异或

  • ~按位非

回答by SQLMenace

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

按位与运算,看看在线书籍中的&(Bitwise AND) (Transact-SQL)

回答by Simmo