SQL Server - boolean literal?(SQL Server - 布尔文字?)
问题描述
如何在 SQL Server 中写入文字布尔值?查看示例使用:
How to write literal boolean value in SQL Server? See sample use:
select * from SomeTable where PSEUDO_TRUE
另一个示例:
if PSEUDO_TRUE
begin
select 'Hello, SQL!'
end
注意:上面的查询与我将如何使用它无关.这只是为了测试文字布尔值.
Note: The query above has nothing to do with how I'm going to use it. It is just to test the literal boolean.
推荐答案
SQL Server 没有布尔值 数据类型.正如@Mikael 所指出的,最接近的近似值是位.但那是数字类型,而不是布尔类型.此外,它只支持 2 个值 - 0 或 1(以及一个非值,NULL).
SQL Server doesn't have a boolean data type. As @Mikael has indicated, the closest approximation is the bit. But that is a numeric type, not a boolean type. In addition, it only supports 2 values - 0 or 1 (and one non-value, NULL).
SQL(标准 SQL,以及 T-SQL 方言)描述了一个三值逻辑.SQL 的布尔类型应支持 3 个值 - TRUE、FALSE 和 UNKNOWN(以及非值 NULL代码>).所以 bit 在这里实际上并不是一个很好的匹配.
SQL (standard SQL, as well as T-SQL dialect) describes a Three valued logic. The boolean type for SQL should support 3 values - TRUE, FALSE and UNKNOWN (and also, the non-value NULL). So bit isn't actually a good match here.
鉴于 SQL Server 不支持 数据类型,我们不应期望能够编写该类型"的文字.
Given that SQL Server has no support for the data type, we should not expect to be able to write literals of that "type".
这篇关于SQL Server - 布尔文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:SQL Server - 布尔文字?
基础教程推荐
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 在多列上分布任意行 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- oracle区分大小写的原因? 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
