Boolean 'NOT' in T-SQL not working on 'bit' datatype?

前端 未结 7 637
闹比i
闹比i 2020-12-13 23:22

Trying to perform a single boolean NOT operation, it appears that under MS SQL Server 2005, the following block does not work

DECLARE @MyBoolean bit;
SET @My         


        
相关标签:
7条回答
  • 2020-12-13 23:49

    Your solution is a good one... you can also use this syntax to toggle a bit in SQL...

    DECLARE @MyBoolean bit;
    SET @MyBoolean = 0;
    SET @MyBoolean = @MyBoolean ^ 1; 
    SELECT @MyBoolean;
    
    0 讨论(0)
提交回复
热议问题