在SQL Server中的select查询中获取默认的额外bool值
如何在select查询中指定bool默认值。我正在使用下面提到的查询进行选择在SQL Server中的select查询中获取默认的额外bool值,sql,sql-server,Sql,Sql Server,如何在select查询中指定bool默认值。我正在使用下面提到的查询进行选择 select null as [<TABLENAME>MyTable</TABLENAME>], 'true' [IsCancel], name, age, location from @TempTable 对布尔值使用位: SELECT null as [<TABLENAME>MyTable</TABLENAME>], CONVERT(bit,1
select null as [<TABLENAME>MyTable</TABLENAME>], 'true' [IsCancel], name, age, location from @TempTable
对布尔值使用
位
:
SELECT
null as [<TABLENAME>MyTable</TABLENAME>],
CONVERT(bit,1) [IsCancel],
name,
age,
location
FROM @TempTable
选择
null为[MyTable],
转换(位,1)[IsCancel],
名称
年龄,
位置
来自“诱惑”
SQL Server没有布尔数据类型-它有位
,根据已经提供的答案,答案类似但不完全相同。由于SQL描述了一个三值逻辑,布尔类型应该支持三个值:true、false和unknown,可空布尔值也应该支持NULL
<代码>位仅支持两个值(1和0)。
SELECT
null as [<TABLENAME>MyTable</TABLENAME>],
CONVERT(bit,1) [IsCancel],
name,
age,
location
FROM @TempTable
SELECT CAST('true' AS BIT) AS [IsCancel]
SELECT CAST('False' AS BIT) AS [IsCancel]