将INT转换为SQL Server中的位

时间:2016-04-14 07:18:54

标签: sql-server

INT值为0且BIT值与0不同时,如果我将INT转换为INT会怎样?

喜欢:

SELECT CAST (0 AS bit)

SELECT CAST (10 AS bit)

1 个答案:

答案 0 :(得分:7)

只需尝试一下:

SELECT CAST (10 AS bit) AS a, CAST (0 AS bit) AS b

返回:

a | b
==+==
1 | 0

这意味着0保持不变,而所有其他整数值将转换为1.