在SQL Server中返回位值为1/0而不是True/False [英] Return Bit Value as 1/0 and NOT True/False in SQL Server
问题描述
我在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屋!