使用 TYPE 作为表值参数的权限

McN*_*ets 3 sql-server sql-server-2014

我正在开发一个 .Net 应用程序,它调用一个存储过程,该存储过程具有一个声明为 TYPE READONLY 的表值参数。

第一次尝试调用 SP 时,我收到了下一个错误:

消息 229,级别 14,状态 5,第 1 行
对象“TYPE_OBJ”、数据库“MY_DB”、架构“dbo”的 EXECUTE 权限被拒绝。

向用户授予 EXECUTE 权限后,它工作正常。

但是我在 MS-DOCS 中都找不到CREATE TYPE使用表值参数中的任何对将其用作参数所需的权限的引用。

在哪里可以找到有关使用 TYPE 作为参数的必要权限的信息?

Dav*_*oft 6

在哪里可以找到有关使用 TYPE 作为参数的必要权限的信息?

我已经针对文档页面提交了 PR 以记录要求。

https://github.com/MicrosoftDocs/sql-docs/pull/3351

这是一个简单的重现:

create type dbo.tt as table(id int)

go

create procedure dbo.ptt @tt tt readonly
as
select * from @tt

go

create user joe without login



grant references on type::dbo.tt to joe
grant execute on dbo.ptt to joe

go

execute as user='joe'

  declare @t tt
  exec ptt @t 
  --The EXECUTE permission was denied on the object 'tt', database 'a', schema 'dbo'.

revert

go

grant execute on type::dbo.tt to joe

go

execute as user='joe'

  declare @t tt
  exec ptt @t 
  --no error

revert
Run Code Online (Sandbox Code Playgroud)