Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Document Stored Procedures

Posted on 2007-12-05
7
Medium Priority
?
755 Views
Last Modified: 2009-03-03
I am looking for a stored procedure or other method that will output the permissions on all stored procedures on my SQL server.  (I have both SQL2000 and SQL2005 instances).  I've been tasked with documenting all of our SQL servers (many) and want to do it more efficiently than pulling the property pages on each and seeing who has what.  I've found a great script that gives me SeverName, DB name, Role name and User Name w/ Id and want to create another loop to include stored procedures, the database name where it resides and the permissions on it.

Your help is appreciated!
0
Comment
Question by:zebra06
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 27

Expert Comment

by:ptjcb
ID: 20412750
There is a system stored procedure

sp_helprotect

It returns information on the stored procedure if you use it as

sp_helprotect 'dbo.stored_procedure_name'

You could either use a cursor or another loop to insert each stored procedure name.

I do not know if this will also work with SQL 2000 databases. I don't have any to test : )

0
 
LVL 11

Expert Comment

by:f_o_o_k_y
ID: 20412802
Try to use attached query.

This is for SQL 2005 but should be similar for 2000

You can use sys views to query usefull information

Best Regards
FooKy




SELECT u.name,  s.name +'.'+ p.name, permission_name FROM sys.procedures p
JOIN sys.schemas s ON (p.schema_id = s.schema_id)
JOIN sys.database_permissions dp ON (dp.major_id = p.object_id)
JOIN sys.sysusers u ON (u.uid = dp.grantee_principal_id)

Open in new window

0
 

Author Comment

by:zebra06
ID: 20429430
FooKy,

Great script for my 2005 instances but I really need to be able to do something similar on my 2k instances as well....I dont see any cooresponding objects to sys.procedures in sql2k.  I'll give partial credit to you for that script but Im still looking for one that does 2k as well......
0
Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
LVL 11

Expert Comment

by:f_o_o_k_y
ID: 20429446
Give me 5 min
and I'll wrote it :) just need to logon. :D
0
 

Author Comment

by:zebra06
ID: 20429610
Fooky, ptjcb's solution works on 2000, just have to write a cursor to get all of them from all databases running on the server.  I'm having a slight issue with yours though.  where do I  run this query?  What context?  (I know, I'm new at this and learning as fast as I can.)
0
 
LVL 11

Accepted Solution

by:
f_o_o_k_y earned 2000 total points
ID: 20429694
Hello,
This is only for Procedures.
If you want to list some other objects you must write some more WHEN acctadd ....... clausule :)
for every premision such as SELECT or INSERT there is different number in acctadd

This is also only for user procedures category =0  (this is not documented filed so im not sure about this.) so check if you have all your procedures if not then delete category = 0.

Best Regards
FooKy
SELECT o.name,u.name,
CASE 
 WHEN p.actadd = 32 and p.actmod = 0 THEN 'EXECUTE'
 WHEN p.actadd = 0 and p.actmod = 32 THEN 'DENY EXECUTE'
 WHEN p.actadd = 32 and p.actmod = 32 THEN 'EXECUTE WITH GRANT'
 ELSE 'THIS IS NOT A PROCEDURE'
END
FROM dbo.syspermissions AS p
JOIN dbo.sysobjects AS o ON (p.id=o.id)
JOIN dbo.sysusers AS u ON (u.uid=p.grantee)
WHERE  o.xtype = 'P' AND  o.category = 0

Open in new window

0
 
LVL 11

Expert Comment

by:f_o_o_k_y
ID: 20429711
Both scirpts should be run in each database.
Because in each database you have different users and can have objects with the same name :)
Best Regards
FooKy
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
In this article, we’ll look at how to deploy ProxySQL.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question