Re: 3 Simple Security SQL Statements
- From: Erland Sommarskog <esquel@xxxxxxxxxxxxx>
- Date: Sun, 24 Jun 2007 22:03:24 +0000 (UTC)
Alex Maghen (AlexMaghen@xxxxxxxxxxxxxxxx) writes:
One more thing, if I may ask: You last example:
SELECT 'GRANT EXECUTE ON ' + quotename(name) + ' TO WebUserRole'
FROM sys.objects
WHERE type = 'P'
AND schema_name(scbema_id) = 'dbo'
Builds a list of text commands. Forgive me for not knowing how to do this,
but how do I actually get Transact-SQL to "execute" each of those
commands?
You could run a cursor over the SELECT statement, and then run EXEC() on
every row.
But it was my intention that you should simply copy and paste, but I
forgot to say that.
And I see also that forgot one condition in the WHERE clause:
AND name LIKE 'HM[_]%'
As for getting things into a schema, it would be as simple to change
HM_some_stored_proc to HM.some_stored_proc. That would of course requires
changes to the application code as well, and it's probably not worth it
only to make it a little easier to set permissions.
By the way, Kalen floated the idea to use a DDL trigger to change the
schema. You could also use a DDL trigger to grant rights to WebUserRole
automatically.
--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.
- References:
- Re: 3 Simple Security SQL Statements
- From: Erland Sommarskog
- Re: 3 Simple Security SQL Statements
- From: Kalen Delaney
- Re: 3 Simple Security SQL Statements
- From: Alex Maghen
- Re: 3 Simple Security SQL Statements
- From: Erland Sommarskog
- Re: 3 Simple Security SQL Statements
- From: Alex Maghen
- Re: 3 Simple Security SQL Statements
- Prev by Date: Re: 3 Simple Security SQL Statements
- Next by Date: Re: No selections in Proxy List (SQL 2005)
- Previous by thread: Re: 3 Simple Security SQL Statements
- Next by thread: Re: No selections in Proxy List (SQL 2005)
- Index(es):
Relevant Pages
|