SQL 更新数据库中的sql位域

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6879999/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 11:31:36  来源:igfitidea点击:

Update sql bit field in database

sqlsql-serverssms

提问by user282807

In a sql table I have a bit field and the value is displayed as True, when I update in code Update table1 set Active='True'it makes the update but the value is now displayed as 1instead of True. How do I make it put the value 'True'instead of the integer in the table? Thanks.

在 sql 表中,我有一个位字段,该值显示为 True,当我在代码中更新时, Update table1 set Active='True'它会进行更新,但该值现在显示为1而不是True. 我如何让它把值'True'而不是整数放在表中?谢谢。

回答by Martin Smith

Bitsin SQL Server are always stored as 1or 0in a bitmap.

Bits在 SQL Server 中始终存储为位图10位图。

The "Edit Table" option in SSMS just translates this to Trueor Falsefor presentation purposes, this is nothing to do with how it is actually stored.

SSMS 中的“编辑表”选项只是将其转换为TrueFalse用于演示目的,这与它的实际存储方式无关。