bigint type with & usage
I am seeing this first time using '&
' symbol in sql stored procedures.
declare @b bigint
set @b=15
select @b&2
result is 2
Can some one ex开发者_运维技巧plain me how the result was 2??
FYI: its on SQL server 2005
&
is the Bitwise And operator.
The result is 2 because;
select 15 --15 as binary: 1111
& 2 --2 as binary: 0010
----
--AND'ing the bits yields; 0010 <- decimal 2
The &
symbol is performs a bitwise logical AND operation between two integer values.
Are you trying to add 2, in which case you may be looking to use:
declare @b bigint set @b=15 select @b + 2
精彩评论