Mark (ma**@hotmailNOSPAMTHANKX.com) writes:
Hi, is there any way that I can automate granting user permissions to
tables/ stored procedures in SQL server 2000?
I have a whole bunch of tables and rather than having to right click each
table/ then permissions in Enterprise manager I would like to be able to
iterate through each table object in a database and grant the relevant
permissions.... Same with stored procedures.
Is this possible?? If so, how can I do it
SELECT 'GRANT SELECT ON ' + name + ' TO whomever'
FROM sysobjects WHERE type = 'U'
SELECT 'GRANT EXEC ON ' + name + ' TO whomever'
FROM sysobjects WHERE type = 'P'
Cut and paste result. Use Query Analyzer for the operation.
If you want to skip the cut-and-paste part, you could set up a cursor
and use dynamic SQL.
--
Erland Sommarskog, SQL Server MVP,
so****@algonet.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp