Permissions Query problem


I have a fleet of databases each of which have read users who  have execute permissions on a set of stored procedures which all start with rpt_.
I would like to be able to list the permissions on these individual logins, but just for the stored procedures defined.

The following would give me one procedure for the user selected:
EXECUTE AS LOGIN = 'read_user_1';
SELECT * FROM fn_my_permissions ('Rpt_x', 'OBJECT');

The above however does not provide the permission info for all the procedures.

Another issue is that I need this to work on sql server 2000 as well as 2005, as half the servers are still 2000.

Can this be done?

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.

Do you want to display the permissions given to database roles also (users may belong to some of them, roles can imply the effective permissions...)?

Some sample code you may use is in the snippet. The code in the snippet searches for execute permissions given to specific users on stored procedures named with prefix rpt_. It does not search for permissions granted (denied) to (from) roles.
  object_name( as [object], 
    when p.protecttype in (204,205) then 'GRANT'
    when p.protecttype = 206 then 'DENY'
  end as [grant/deny]
from dbo.sysprotects p with (nolock)
inner join dbo.sysusers u with (nolock)
on p.uid = u.uid
inner join sysobjects o with (nolock)
on =
where like 'rpt\_%' escape '\' 
and in (<put_your_user_names_list_here>) 
and p.action = 224 and o.xtype = 'P'

Open in new window


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
kinnon_2000Author Commented:
This was great. sorry for the delayed response, I've been away for a short spell.
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

From novice to tech pro — start learning today.