SQL Server in-memory : Native compile with Execute as Owner

sakuraime 2,351 Reputation points
2020-10-23T09:23:52.817+00:00

https://learn.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/native-compilation-of-tables-and-stored-procedures?view=sql-server-ver15

34546-owner.jpg

May i know is it a must to mention Execute as Owner during the creation of native compile sp ? I can create without Execute as Owner .

SQL Server | Other
0 comments No comments
{count} votes

Answer accepted by question author
  1. Erland Sommarskog 128.7K Reputation points MVP Volunteer Moderator
    2020-10-23T21:58:30.413+00:00

    A small correction to Dan and Tibor: In SQL 2014 EXECUTE AS OWNER was mandatory. They removed that requirement in SQL 2016. But this can explain why it still appears in some samples.


2 additional answers

Sort by: Most helpful
  1. Dan Guzman 9,411 Reputation points
    2020-10-23T09:57:23.143+00:00

    The EXECUTE AS clause is not required for natively compiled stored procedures. The syntax diagram for natively compiled stored procedures in the CREATE PROCEDURE documentation page shows the clause in square brackets, indicating it is optional.

    0 comments No comments

  2. tibor_karaszi@hotmail.com 4,316 Reputation points
    2020-10-23T10:02:01.44+00:00

    It is not a must. I can also create without specifying EXECUTE AS.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.