Simple Grants Cursor Script

Sunday Jan 12th 2003 by DatabaseJournal.com Staff
Share:

A simple cursor script that will look for User objects and grant access to a user or group.



Here's a simple cursor script that will look for User objects and grant access to a user or group. The script could also be adapted to perform a REVOKE command rather than a GRANT privilege. It's really an admin tool, but you could use it to trigger or limit a Database user's application privileges. Really you would want to first examine the Application Role set-up in SQL 2000 to promote and demote a SQL User's privileges.

Here's an example to demonstrate adding permissions to a database user under SQL 7/2000:

Author: Jack C. Donnell


GRANT 
    { ALL [ PRIVILEGES ] | permission [ ,...n ] } 
    { 
        [ ( column [ ,...n ] ) ] ON { table | view } 
        | ON { table | view } [ ( column [ ,...n ] ) ] 
        | ON { stored_procedure | extended_procedure } 
        | ON { user_defined_function }
    } 
TO security_account [ ,...n ] 
[ WITH GRANT OPTION ] 
[ AS { group | role } ] 

and one for performing a revoke command: 
REVOKE [ GRANT OPTION FOR ] 
    { ALL [ PRIVILEGES ] | permission [ ,...n ] } 
    { 
        [ ( column [ ,...n ] ) ] ON { table | view } 
        | ON { table | view } [ ( column [ ,...n ] ) ] 
        | ON { stored_procedure | extended_procedure } 
        | ON { user_defined_function } 
    } 
{ TO | FROM } 
    security_account [ ,...n ] 
[ CASCADE ] 
[ AS { group | role } ] 



Disclaimer: We hope that the information on these script pages is valuable to you. Your use of the information contained in these pages, however, is at your sole risk. All information on these pages is provided "as -is", without any warranty, whether express or implied, of its accuracy, completeness, or fitness for a particular purpose... Disclaimer Continued

Back to Database Journal Home

Share:
Home
Mobile Site | Full Site
Copyright 2017 © QuinStreet Inc. All Rights Reserved