How to set bool value in SQL

后端 未结 4 1841
天涯浪人
天涯浪人 2020-11-30 14:39

I have a column which is bool. How can I set true, false values for that? Here is my query :

Update [mydb].[dbo].[myTable]
SET isTrue =
(
CASE WHEN Name = \         


        
4条回答
  •  时光说笑
    2020-11-30 15:41

    The query you added will work fine, but it will you have to take care of "FALSE" part as well otherwise it will try to enter NULL in your column. Do you have any default value constrain on isTrue column?

    Update [mydb].[dbo].[myTable]
    SET isTrue =
    (
       CASE WHEN Name = 'Jason' THEN 1 ELSE 0
    END
    )
    

提交回复
热议问题