是“执行”在本地编译的存储程序中必须进行强制性?
我注意到,使用execute作为所有者
定义了本质上编译存储过程(在SQL Server中)的所有示例(在SQL Server中)。
例如:
CREATE PROCEDURE [dbo].[InsertOrderXTP]
@id INT,
@date DATETIME2,
@status TINYINT
WITH NATIVE_COMPILATION, SCHEMABINDING, EXECUTE AS OWNER
AS...
我们开始遇到以下错误,同时尝试执行使用执行为所有者
的本质编译的存储过程:
无法获得有关Windows NT组/用户的信息...
这很有意义,因为我们与创建这些过程的用户还有其他无关的技术问题。
由于我们从未在常规(“解释”)过程中使用执行为..
,因此我尝试将其从本质编译的存储过程中删除,并且似乎工作正常。
但是,正如我提到的,它与我见过的所有示例相比,我找不到在这个问题上详细阐述的任何相关文档。
- 使用
执行为所有者...
“?? - 必须 t定期(解释)存储程序存在
- ?
I noticed that all examples (that I've seen) of natively compiled stored procedures (in SQL Server) are defined using EXECUTE AS OWNER
.
CREATE PROCEDURE [dbo].[InsertOrderXTP]
@id INT,
@date DATETIME2,
@status TINYINT
WITH NATIVE_COMPILATION, SCHEMABINDING, EXECUTE AS OWNER
AS...
We started getting the following error while trying to execute natively compiled stored procedures we created with EXECUTE AS OWNER
:
Could not obtain information about Windows NT group/user ...
This make sense because we had other un-related technical issue with the user that created those procedures.
Since we never used EXECUTE AS ..
in regular ("interpreted") procedures, I tried removing it from the natively compiled stored procedure and it seems to to be working just fine.
But as I mentioned, it contrast from all the examples I've seen, and I couldn't find any relevant documentation that elaborates on this issue.
- Must a natively compiled stored procedures be created with
EXECUTE AS OWNER...
"? - Is there a benefit to creating natively compiled stored procedures with
EXECUTE AS OWNER...
that doesn't exist in regular (interpreted) stored procedures? - Where can I find explicit documentation about this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这似乎是SQL Server 2016不再需要的历史限制
。 -transact-sql?view = sql-server-ver15#execute-as-clause“ rel =“ nofollow noreferrer”>创建过程的文档,我们有此注释:
然后在关于执行为的单独页面是这样的:
将这两件事放在一起,我们发现在SQL Server 2014中本质上编译的存储过程中省略执行子句将默认为无支持的选项。因此,所有本质上编译的存储过程的示例均早于SQL Server 2016,将需要明确执行作为子句才能成功编译。
This appears to be a historical limitation that is no longer required as of SQL Server 2016.
In the documentation for CREATE PROCEDURE, we have this note:
Then on the separate page about EXECUTE AS there is this:
Put those two things together, and we find that omitting the EXECUTE AS clause on a natively compiled stored procedure in SQL Server 2014 would have defaulted to an unsupported option. So all examples of natively compiled stored procedures which predate SQL Server 2016 would have needed an explicit EXECUTE AS clause to compile successfully.