I had a table with two columns: ID and Description. The task was to display the description of all elements whose ID is a power of two. Here’s the query that let me accomplish that: SELECT ID, Desc FROM tblBits WHERE ID > 0 AND ID & (ID-1) = 0 How does this work? Every [...]
Filed under: Microsoft, SQL, SQL Server, Technical | 1 Comment »