Table valued parameter in a stored procedure gets execute permissions denied error

后端 未结 3 612
太阳男子
太阳男子 2021-01-07 18:33

I get the following error when calling a stored procedure that has a table valued parameter as one of the parameters

The EXECUTE permission was denied

3条回答
  •  既然无缘
    2021-01-07 18:52

    As @chiefbrownbotom says, the reason why you need execute permissions on the table type is that the table is created before (and therefore outside of) the call to the proc. To illustrate this run a SQL Profiler trace and call your proc. You will see something like this which might surprise you...

    DECLARE @p1 TABLE AS YourTableType
    INSERT INTO @p1 (col1, col2, col3) VALUES ('val1','val2','val3')
    INSERT INTO @p1 (col1, col2, col3) VALUES ('val1','val2','val3')
    ...
    EXEC usp_YourStoredProc @p1
    

提交回复
热议问题