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

前端 未结 7 650
闹比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:27

    Use the ~ operator:

    DECLARE @MyBoolean bit
    SET @MyBoolean = 0
    SET @MyBoolean = ~@MyBoolean
    SELECT @MyBoolean
    

提交回复
热议问题