在 SQL Server 中将位值返回为 1/0 而不是 True/False [英] Return Bit Value as 1/0 and NOT True/False in SQL Server

查看:39
本文介绍了在 SQL Server 中将位值返回为 1/0 而不是 True/False的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 SQL Server 2000 中有一个带有 BitValue 列的表.但是,它在 SQL Server Management Studio 中显示为 True/False.当我执行 Select * from Tablename 时,它会将 BitValue Column 值返回为 True/False.如何强制它以位 (1/0) 而不是 True/False 形式返回值?任何帮助将不胜感激?

I have a Table in SQL Server 2000 with BitValue Column. But, it is being displayed as True/False in SQL Server Management Studio. When I do a Select * from Tablename it returns the BitValue Column values as True/False. How do I force it to return the value as bits (1/0) instead of True/False? Any Help will be really appreciated?

推荐答案

试试这个脚本,也许会有用:

Try with this script, maybe will be useful:

SELECT CAST('TRUE' as bit) -- RETURN 1
SELECT CAST('FALSE' as bit) --RETURN 0

无论如何,我总是会使用 1 或 0 的值(不是 TRUE 或 FALSE).按照您的示例,更新脚本将是:

Anyway I always would use a value of 1 or 0 (not TRUE or FALSE). Following your example, the update script would be:

Update Table Set BitField=CAST('TRUE' as bit) Where ID=1

这篇关于在 SQL Server 中将位值返回为 1/0 而不是 True/False的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆