• Thanks for raising another interesting topic. I had never considered the performance benefits of doing things this way, but have used the method for other reasons (sometimes you simply don't need a reference data table).

    Anyway, using your example schema, I just thought I'd highlight the fact that the "traditional" result set of all errors for a/all users can also be generated using the bitwise method.

    Cheers,

    Daniel

    ***************************************

    DECLARE @user-id int

    SET @userid = 3

    -- return all errors for a user using the bitwise method in a join

    SELECT U.*, E.*

    FROM Users U

    JOIN Errors E

    ON E.ErrorFlag & U.UserErrorFlag = E.ErrorFlag

    WHERE U.Userid = @userid

    -- return all errors for a user using a join to the many-to-many intermediate table

    SELECT U.*, E.*

    FROM Users U

    JOIN UserErrors UE

    ON UE.UserId = U.UserId

    JOIN Errors E

    ON E.ErrorId = UE.ErrorId

    WHERE U.UserId = @userid