I recently migrated a database to SQL Azure. When I try to execute a stored procedure on this database on SQL Azure, I receive the following error:
The EXECUTE permission was denied on the object 'Log_Save', database 'MyDatabase', schema 'dbo'.
My question is, how do I grant EXECUTE permissions to stored procedures (as well as read/write access to tables) on SQL Azure?
thank you!
To grant permissions for the user, switch to the Object Permissions tab. In the Objects block, select the database object on which you want to grant privileges. In the Available Privileges block, select the permissions to be assigned and click Save.
SQL Server includes a very useful system function sys. fn_my_permissions to list all the permissions of a particular principal (user or login) and this system function will help you list all permissions of a principal on a specific database object (securable).
Related to Joe Abrams' answer, you can grant execute permission to an individual user:
GRANT EXECUTE TO testuser
GO
The trick is that you have to create a custom "executor" role and then grant execute permissions to it.
In your master DB, first create a user if you don't have one already:
CREATE USER MyUser FOR LOGIN MyLogin WITH DEFAULT_SCHEMA=[dbo]
GO
Then, in your new DB:
CREATE ROLE [db_executor] AUTHORIZATION [dbo]
GO
GRANT EXECUTE TO [db_executor]
GO
sp_addrolemember @rolename = 'db_executor', @membername = 'MyUser'
sp_addrolemember @rolename = 'db_datareader', @membername = 'MyUser'
sp_addrolemember @rolename = 'db_datawriter', @membername = 'MyUser'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With