Wednesday, March 25, 2009

Grant objects permission to users in SQL Server 2000

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 user
 [ ,...n

Arguments:

ALL

Specifies that all applicable permissions are being granted

permission

Is an object permission that is being granted.  

For table, table-valued function, or a view: 

SELECT, INSERT, DELETE, REFERENCES, or UPDATE. A column-list can be supplied along with SELECT and UPDATE permissions. If a column-list is not supplied with SELECT and UPDATE permissions, then the permission applies to all the columns in the table, view, or table-valued function.

For stored procedure: EXECUTE. 

column

Is the name of a column in the current database for which permissions are being granted.

table

Is the name of the table in the current database for which permissions are being granted.

view

Is the name of the view in the current database for which permissions are being granted.

stored_procedure

Is the name of the stored procedure in the current database for which permissions are being granted.

extended_procedure

Is the name of the extended stored procedure for which permissions are being granted.

user_defined_function

Is the name of the user-defined function for which permissions are being granted.

user

Is name of user whom permission should be granted. 

Example:

To grant a permission to table employee in database Emp to user hitesh :

GRANT ALL ON [emp].[employee] TO [hitesh]


No comments:

Post a Comment