Boolean 'NOT' in T-SQL not working on 'bit' datatype?
        Posted  
        
            by Joannes Vermorel
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Joannes Vermorel
        
        
        
        Published on 2008-10-07T09:35:24Z
        Indexed on 
            2010/04/07
            2:33 UTC
        
        
        Read the original article
        Hit count: 505
        
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 @MyBoolean = 0;
SET @MyBoolean = NOT @MyBoolean;
SELECT @MyBoolean;
Instead, I am getting more successful with
DECLARE @MyBoolean bit;
SET @MyBoolean = 0;
SET @MyBoolean = 1 - @MyBoolean;
SELECT @MyBoolean;
Yet, this looks a bit a twisted way to express something as simple as a negation.
Am I missing something?
© Stack Overflow or respective owner