From the documentation Create a Stored Procedure:
Permissions
Requires CREATE PROCEDURE permission in the database and ALTER
permission on the schema in which the procedure is being created.
Therefore just giving CREATE PROCEDURE
on it's own won't allow you to create a procedure. In fact, giving a ROLE
the CREATE PROCEDURE
permission, and not ALTER
on the schema will result in the below error:
The specified schema name "dbo" either does not exist or you do not have permission to use it.
There is no ALTER PROCEDURE
permissions, therefore, for a member of a ROLE
to be able to both CREATE
and ALTER
a PROCEDURE
you would need to do:
GRANT CREATE PROCEDURE TO YourRole;
GRANT ALTER ON SCHEMA::dbo TO YourRole; --Replace with appropriate schema name
This, however, will also enable to user to ALTER
anyprocedures on said schema. Ut also enable those in the role to ALTER
other objects on the schema as well (such as tables) though.
If your ROLE
has permissions to ALTER
the procedures and you want to remove that, you would need to run the below:
REVOKE ALTER ON SCHEMA::dbo TO YourRole;
This will, as mentioned, also revoke their ability to ALTER
any other objects on said schema.
Remember, REVOKE
doesn't DENY
, it simply means that the USER
won't inherited that permission from that ROLE
any more. If the USER
has the permission from a different ROLE
, or they have the permission themselves, they will be able to continue to use the permission. If you must stop a USER
from performing an action, regardless of any other permissions, they must have the DENY
permission.