I have a user table, a role table that holds roleID and name, and a userrole table that has roleID and userID. Users can have multiple roles, so there could be multiple records returned for my select query. Is there a way that I can combine each roleID into a single row with a new column added for the additional roleID if it exists, either through a sql proc or in VB? I have a gridview that I will use for role management, it has 3 columns for roles, each with a checkbox that allows adding or deleting a role.
1 Answer
Don't store multiple items in a single database column; you're violating first normal form, which is not good database design.
In your case, you could create a View that aggregates your multiple roles into a single "column" (comma delimited), and then base your gridview's datasource on the new View, instead of the base table.
You could do the same thing through a stored procedure.