How to grant an object permission in one db to a user/role which resides in another db


In SQL Query Analyzer, I execute:

Use mydatabase
grant execute on getDate to rolegroup

(getDate is a user defined stored procedure, rolegroup is a user defined role)

This is ok.

What would be the syntax like if I want to grant a permission to a user/role whom resides in another database.

Is there something like
grant execute on getDate to anotherdatabase@rolegroup

This is crucial for example if an object resides in master database and I need to grant the object to another database user/role.


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Role are entities within the database and can only be granted permissions on objects within that database.

Put the role in the two databases, put the same users in each then you should be able to grant access within the database.

In fact from bol for Grant
Creates an entry in the security system that allows a user in the current database to work with data in the current database or execute specific Transact-SQL statements.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I agree with nigelrivett (points to him)
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.
deschewAuthor Commented:
Thank you.

But it seems that by putting same role in another database will violate some security issues.

If I am not mistaken the system stored procedure sp_sdidebug is contained inside 'Master' database. If a users in 'Newdatabase' wish to use this system stored procedure, he needs to be in Master database.

Another way is to grant it to the public.

This is the case of system procedure.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

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.