title: Can I perform a bitwise and on a set of numbers in Sql Server?
body: <p>I have a security table containing a list of groups and users with a bitwise integer permission for each.  For each given user, I would like to perform a bitwise AND on all of their groups and of their personal permission record, if present.</p>
  
  <p>Of course, I can easily do this in my code, but I'd rather do it in the database as there could be thousands of items I am querying the rights for.</p>
  
  <p>I would prefer a set-based solution over a cursor.</p>
  
  <p>Note than I do not have control over the schema.</p>