• Todd Young-359443 - Friday, January 20, 2017 12:28 PM

    We are not looking at the values in relation to size but which bits are set. The general rules for is as far as bits themselves go are:
    1 or 1 = 1
    0 or 0 = 0
    1 or 0 = 1

    Todd

    A case statement? For example:
    CREATE TABLE #BIT (ID INT IDENTITY(1,1),
           BitValue1 BIT,
           BitValue2 BIT);
    GO

    INSERT INTO #BIT
    VALUES (1,1),
           (1,0),
           (0,1),
           (0,0);
    GO

    SELECT *,
           CASE WHEN BitValue1 = 1 OR BitValue2 = 1 THEN 1 ELSE 0 END AS OrValue,
           CASE WHEN BitValue1 = 0 AND BitValue2 = 0 THEN 0
                WHEN BitValue1 = 1 AND BitValue2 = 1 THEN 0
                ELSE 1 END AS XorValue
    FROM #BIT;

    DROP TABLE #BIT;
    GO

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk