Solved

Document Stored Procedures

Posted on 2007-12-05
7
753 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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 500 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

623 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