sql server/database roles.

We have a setup on a SQL 2012 server in which there are views and stored procedures on one database that pull from tables on another database (same server). So as far as I can figure out when we need a login to have access to the view we also need to grant rights on the 'tables' database as well. So we have add permissions to one of the databases and then to the other database each time we have a new user that needs access.   If there is no way around this, I would like to create something like a role which is set up with the permissions to the two databases, and then we just add users to the role.

I am reading about 2012 Server Roles and am not figuring out how to do this.
Who is Participating?
DBAduck - Ben MillerConnect With a Mentor Principal ConsultantCommented:
I would not enable database ownership chaining unless it is the last resort. This is a security feature that circumvents some things.  I would create a role in the other database, assign permissions to the database role and map the user of the current database to that database and give that user membership in the role.
ste5anConnect With a Mentor Senior DeveloperCommented:
You need to enable database chaining. This requires only connect permissions on the other database.
Vitor MontalvãoConnect With a Mentor MSSQL Senior EngineerCommented:
Please read my articles about Views. If after that you still not able to solve your issue, then let me know, so I can help you further.

Understanding the Views scope (i) - Limiting the access to data
Understanding the Views scope (ii) - Ownership chaining
Understanding the Views scope (iii) - The complete security layer
Vitor MontalvãoMSSQL Senior EngineerCommented:
Recommendation to close this question by accepting the above comments as solution.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.