在SQL Server 中,可以使用GRANT EXECUTE命令为用户或角色授予执行存储过程的权限。以下是一个示例: GRANTEXECUTEONdbo.StoredProcedureNameTOUserName; 1. 上面的代码中,GRANT EXECUTE表示授予执行权限,dbo.StoredProcedureName是要授予权限的存储过程的名称,UserName是接收权限的用户或角色的名称。 需要注意的是,只有拥有对...
使用以下T-SQL语句来授予执行权限: GRANTEXECUTEONMyStoredProcedureTOJohnDoe; 1. 这条语句的意思是授予用户JohnDoe对存储过程MyStoredProcedure的执行权限。 步骤4:测试权限 以用户JohnDoe的身份登录到SQL Server,并尝试执行存储过程: EXECMyStoredProcedure; 1. 如果执行成功,说明权限已经成功授予。 步骤5:处理错误 ...
-- Grants EXECUTE permission on stored procedure HumanResources.uspUpdateEmployeeHireInfo to an application role called Recruiting11.USEAdventureWorks2022; GOGRANTEXECUTEONOBJECT::HumanResources.uspUpdateEmployeeHireInfoTORecruiting11; GO 有关详细信息,请参阅GRANT(Transact-SQL)和GRANT 对象权限(Transact-SQL)...
1--Grant permissions on the stored procedure2GRANTEXECUTEONSchemaUserProc.VendorAccessProcTORealUser;3GO 代码6.2:在新的存储过程上授予EXECUTE许可。 在SSMS里,你可以运行EXECUTE AS作为临时修改安全上下文的在查询窗体里运行的代码语句。使用代码6.3修改安全上下文为RealUser来运行存储过程获得在位于阿拉斯加的供应商列表。
This example grants EXECUTE permission on the stored procedure HumanResources.uspUpdateEmployeeHireInfo to an application role named Recruiting11.SQL Ikkopja USE AdventureWorks2022; GRANT EXECUTE ON OBJECT::HumanResources.uspUpdateEmployeeHireInfo TO Recruiting11; GO ...
如果随后执行了存储过程,而现有执行计划仍留在内存中,则 SQL Server 将重用现有执行计划。如果执行计划不再位于内存中,则创建新的执行计划。 存储过程安全性 在sa账号下面,执行了下面这条语句 DENYINSERTONdbo.EmployeeTOKerry; GRANTEXECUTEONdbo.USP_AddEmployeTOKerry; ...
If all objects in the chain of execution have the same owner, then SQL Server only checks the EXECUTE permission for the caller, not the caller's permissions on other objects. Therefore you need to grant only EXECUTE permissions on stored procedures; you can revoke or deny all permissions on...
EXEC sp_addrolemember TesterRole, User1;-- Execute the following as User1-- The following fails because User1 does not have the permission as the User1GRANTEXECUTEONTestProcTOUser2;-- The following succeeds because User1 invokes the TesterRole membershipGRANTEXECUTEONTestProcTOUser2ASTesterRole;...
EXEC sp_addrolemember TesterRole, User1;-- Execute the following as User1-- The following fails because User1 does not have the permission as the User1GRANTEXECUTEONTestProcTOUser2;-- The following succeeds because User1 invokes the TesterRole membershipGRANTEXECUTEONTestProcTOUser2ASTesterRole;...
If all objects in the chain of execution have the same owner, then SQL Server only checks the EXECUTE permission for the caller, not the caller's permissions on other objects. Therefore you need to grant only EXECUTE permissions on stored procedures; you can revoke or...