存储过程中的表值参数获取执行权限被拒绝错误 [英] Table valued parameter in a stored procedure gets execute permissions denied error
问题描述
当调用具有表值参数作为参数之一的存储过程时,出现以下错误
I get the following error when calling a stored procedure that has a table valued parameter as one of the parameters
EXECUTE
对象 ValidationErrors的权限被拒绝
The EXECUTE
permission was denied on the object 'ValidationErrors'
ValidationErrors是使用以下语句创建的TVP:
ValidationErrors is a TVP created with the following statement:
CREATE TYPE [dbo].[ValidationErrors] AS TABLE(
[ErrorMessage] [varchar](255) NOT NULL
)
执行存储过程的用户对存储过程具有执行特权。但是,我仍然收到上述错误。
有什么想法吗?
The user executing the stored procedure has execute privileges on the stored procedure. However, I still get the above error. Any ideas?
推荐答案
我认为您可能还需要授予用户对该类型的权限。
I think you may also need to grant the user permissions to the type.
References for GRANTing permissions to types:
SQL 2005
SQL 2008
更新:
Re:为什么当您对sproc拥有权限时,必须授予该类型的权限。
我不知道确定的原因,但是 BOL 说:
与
使用sp_addtype创建的用户定义类型不同,公共数据库
不会自动为
角色授予
通过使用CREATE TYPE创建的
类型的权限。此
权限必须单独授予。
Unlike user-defined types created by using sp_addtype, the public database role is not automatically granted REFERENCES permission on types that are created by using CREATE TYPE. This permission must be granted separately.
更新2:
授予GRANT执行权限,您可以在SSMS中运行它:
Update 2: To GRANT EXECUTE permissions, you'd run this in SSMS:
GRANT EXECUTE ON TYPE::dbo.ValidationErrors TO SomeUser;
这篇关于存储过程中的表值参数获取执行权限被拒绝错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!