Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 BitOr a column of values

Author  Topic 

inrsence
Starting Member

48 Posts

Posted - 2001-11-01 : 00:24:47
Hello all,

I'm trying to build a User/Group security model and was planning on using the bitwise operators to manage permissions.

I've got a table for Groups:
GroupID int (PK)
Permissions tinyint

Also there is a table for User_Groups:
UserID int (PK)
GroupID int (PK)

I was originally going to store the composite number for the user's rights but that created a need to update aeach user when the group was changed.

The approach I am using now should let me join pack to Groups to get the permissions.

What I want to get as a result is:
UserID int
Permissions int

where Permissions is actually the | (BitOr) of each of the permission for each group the user is a member of.

I can do this from the application level.. but is there a way to do it with a single SQL statement?

Thanks in advance,
greg
   

- Advertisement -