clear markdown compare help best fiddles feedback a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 1716874 fiddles created (23891 in the last week).

CREATE FUNCTION fnGetBitsForMask (@Mask INT) RETURNS TABLE AS RETURN WITH BitwiseValues AS ( SELECT CAST(1 AS INT) AS RowNumber, CAST(0 AS INT) AS BitValue UNION ALL SELECT b1.RowNumber+1 AS RowNumber, POWER(2, b1.RowNumber-1) AS BitValue FROM BitwiseValues b1 WHERE b1.RowNumber < 30 ) SELECT b.BitValue FROM BitwiseValues b CROSS JOIN (SELECT @Mask AS Mask) m WHERE b.BitValue & m.Mask > 0
 hidden batch(es)

SELECT * FROM dbo.fnGetBitsForMask(11)
 hidden batch(es)