I cannot find the syntax error

  • create procedure p2

    with execute as login = 'my_login'

    as

    begin

    select 1

    end

    can you tell me why I'm getting:

    Msg 102, Level 15, State 1, Procedure p2, Line 2

    Incorrect syntax near 'login'.

  • Try:

    create procedure p2

    with execute as 'my_login'

    as

    begin

    select 1

    end

  • No, i want to execute as the Login, not as the User. Accordingly BOL i had to specify the keyword LOGIN, or?

    <context_specification>::=

    { LOGIN | USER } = 'name'

    [ WITH { NO REVERT | COOKIE INTO @varbinary_variable } ]

    | CALLER

  • It looks like you're confusing two different types of EXECUTE.

    There's the EXECUTE AS Clause, which applied to functions, procedures and suchlike,

    then there is the EXECUTE (<command or character string>) AS clause.

    Check a little close with BOL for 'EXECUTE AS' and 'EXECUTE AS Clause' - two different bits.

    BrainDonor.

    Steve Hall
    Linkedin
    Blog Site

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply