|
sql
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Bitwise in SQL Server
Ok, I am just exploring the Bitwise operations in SQL. I like the fact
that I can take a field called GroupID int, and store the Groups in which the user is subscribed to. such as Group 1 and Group 16. and all I have to do to check if the user is in that group, I do: (GroupID&2)=2 That's kind of nice. But problem, I cannot create more than 32 groups b/c of integer calculations limit. What is the best way to go about this? Is there a trick to be able to increase the options other than the following: - BigInt: which will have its own limit in the end. - Or creating a relationship Member_Group table as usual. Thanks every genius person in advance. I would actually parse it off into a table of subscribed groups and then use
relational division to determine if a user is a member of a specific set of groups. Alternatively, if you are looking for membership in a single group, then it's a simple SELECT. -- Tom ---------------------------------------------------- Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS SQL Server MVP Toronto, ON Canada https://mvp.support.microsoft.com/profile/Tom.Moreau "mr t" <tasc***@gmail.com> wrote in message Ok, I am just exploring the Bitwise operations in SQL. I like the factnews:84a6973b-625f-4345-9bf0-80d98833b3f5@u18g2000pro.googlegroups.com... that I can take a field called GroupID int, and store the Groups in which the user is subscribed to. such as Group 1 and Group 16. and all I have to do to check if the user is in that group, I do: (GroupID&2)=2 That's kind of nice. But problem, I cannot create more than 32 groups b/c of integer calculations limit. What is the best way to go about this? Is there a trick to be able to increase the options other than the following: - BigInt: which will have its own limit in the end. - Or creating a relationship Member_Group table as usual. Thanks every genius person in advance. > That's kind of nice. But problem, I cannot create more than 32 groups How many groups you talking about???> b/c of integer calculations limit. > > What is the best way to go about this? Is there a trick to be able to > increase the options other than the following: Maybe use a second field ... in
news:84a6973b-625f-4345-9bf0-80d98833b3f5@u18g2000pro.googlegroups.com, mr t wrote :Show quoteHide quote > Ok, I am just exploring the Bitwise operations in SQL. I like the fact If you plan to use this in WHERE clauses, it's a false good idea as SQL > that I can take a field called GroupID int, and store the Groups in > which the user is subscribed to. such as Group 1 and Group 16. and all > I have to do to check if the user is in that group, I do: > > (GroupID&2)=2 > > That's kind of nice. But problem, I cannot create more than 32 groups > b/c of integer calculations limit. > > What is the best way to go about this? Is there a trick to be able to > increase the options other than the following: > > - BigInt: which will have its own limit in the end. > - Or creating a relationship Member_Group table as usual. won't be able to optimize the query execution plan. As Tom said, I also use the Member_Group table. And if you are looking for something like row based access control, you can have a look here : http://www.microsoft.com/technet/prodtechnol/sql/2005/multisec.mspx -- Fred fole***@free.fr
Other interesting topics
cmdshell how to run server side vbscript
Issue with subselect Lumigent Log Explorer - where to get it? NCHAR -> CHAR COLLATION problems INSERT'ing from SQL Server into DB2 HTTP T-SQL queries (with XML support) don't work on sql server 200 Retaining same Instance Name in side-by-side upgrade/migration issue with data format in joining tables Connections between 2 SQL Servers Server Side Trace wierdness |
|||||||||||||||||||||||