Thursday 6 March 2014

How to grant the execute permission to User on all the procedure of the database?

SQL Server 2005 onward, we can create the roles in database. You can follow below simple script to grant the EXECUTE permission to user.
   
-- creating the database role
CREATE ROLE Database_Executor
-- granting the execute permission to database role
GRANT EXECUTE TO Database_Executor

-- Here I am granting the SQLDB login execute permission
USE [DBName]
GO
CREATE USER [SQLDB] FOR LOGIN [sqldb]
GO
USE [DBName]
GO
EXEC sp_addrolemember N'Database_Executor', N'sqldb'
GO

No comments:

Post a Comment