给用户添加执行存储过程权限
1.创建给用户添加执行存储过程权限的存储过程
create procedure p_addexec
@username varchar(50)
as
CREATE ROLE [execp] AUTHORIZATION [dbo]
declare @strRole varchar(50)
declare @str varchar(5000)
set @str=''
set @strRole='execp'
select @str=@str+'grant execute on '+name+' to '+@strRole+';' from sysobjects where xtype= 'p '
exec (@str)
EXEC sp_addrolemember N'execp',@username
GO
2.执行
exec p_addexec 用户名