|
Introduction to Rights and Permissions |
|
|
|
A permission is an action that a user is allowed to
perform, or is prevented from performing, on a database or on one of its
objects.
|
In order to do something on the server or one of its
objects, a user must be given the permission. This is also referred to as
granting a permission. To grant permissions, the account you are using must
have the ability to do so. This means that, before granting permissions, you
must log in with an account that has its own right permissions. You can
grant permissions visually or with code.
To visually grant one or more permissions on the server,
in the Object Explorer, right-click the name of the server and click
Properties. In the left frame of the Server Properties dialog box, click
Permissions. In the Logins or Roles list, click the name of the user. In the
bottom list, use the options in the Grant column:

The basic formula to
programmatically grant one or more permissions is:
GRANT Permission TO Login
You start with the GRANT keyword followed by the
name of the permission. After the permission, type TO,
followed by the login name you want to grant the permission to. Here is an
example that gives operez to create a database on the server:
USE master;
GO
GRANT CREATE ANY DATABASE
TO operez;
GO
If you want to grant more than one permission, separate
their names with commas. Here is an example:
GRANT CREATE ANY DATABASE, SHUTDOWN
TO operez;
GO
If you want to grant the same permission(s) to more than
one account, list them, separated by commas. Here is an example:
GRANT CREATE ANY DATABASE, ALTER ANY LOGIN
TO pkatts, gdmonay;
GO