Tsql sql中的运算符是什么?它是如何工作的
我想知道以下条件是如何工作的:Tsql sql中的运算符是什么?它是如何工作的,tsql,sql-server-2008,Tsql,Sql Server 2008,我想知道以下条件是如何工作的: where x1 | x2 | x3 | x4 is not null 列x1、x2、x3、x4可为空 是一样的吗 where x1 is not null or x2 is not null or x3 is not null or x4 is not null 这是一个按位OR。你 试试这个: DECLARE @int1 INT=0xFF00; -- => 65280 DECLARE @int2 INT=0x000F; --
where x1 | x2 | x3 | x4 is not null
列x1、x2、x3、x4可为空
是一样的吗
where x1 is not null or x2 is not null or x3 is not null or x4 is not null
这是一个按位OR。你
试试这个:
DECLARE @int1 INT=0xFF00; -- => 65280
DECLARE @int2 INT=0x000F; -- => 15
DECLARE @int3 INT=@int1 | @int2; -- => 65295
SELECT @int1,@int2,@int3,
CAST(@int3 AS BINARY(2));-- => 0xFF0F
您可以看到,@int1
和@int2
的位掩码被组合为0xFF0F
这可用于检查或设置一个特殊位或一组位 这是一个按位OR。你
试试这个:
DECLARE @int1 INT=0xFF00; -- => 65280
DECLARE @int2 INT=0x000F; -- => 15
DECLARE @int3 INT=@int1 | @int2; -- => 65295
SELECT @int1,@int2,@int3,
CAST(@int3 AS BINARY(2));-- => 0xFF0F
您可以看到,@int1
和@int2
的位掩码被组合为0xFF0F
这可用于检查或设置一个特殊位或一组位