Mr_Shaw
asked on
SQL error running WITH EXECUTE AS
I tried to add the following to my stored procedure but it did not work
WITH EXECUTE AS 'sa'
I got an error reading.
Cannot execute as the user 'sa', because it does not exist or you do not have permission.
WITH EXECUTE AS 'sa'
I got an error reading.
Cannot execute as the user 'sa', because it does not exist or you do not have permission.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
how about
WITH EXECUTE AS LOGIN = 'sa'
WITH EXECUTE AS LOGIN = 'sa'
Inside stored procedure use as: WITH EXECUTE AS 'dbo'
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
using dbo through back a permission error.
I'll read through all the material and try again.
Thanks
I'll read through all the material and try again.
Thanks
Dear Mr_Shaw:
EvilPostIt: post to use dbo instead of sa will solve your initial problem but soon after that you will get the below error
The server principal "User" is not able to access the database "DB" under the current security context.
so i suggest reading the article i posted above and knowing every thing about Execute as before using it, its not a straight forward thing and has many considerations.
Regards
EvilPostIt: post to use dbo instead of sa will solve your initial problem but soon after that you will get the below error
The server principal "User" is not able to access the database "DB" under the current security context.
so i suggest reading the article i posted above and knowing every thing about Execute as before using it, its not a straight forward thing and has many considerations.
Regards
Hi AmmarR.
Agreed, you should always know what your using. Plus with my original posting i didnt realise this was executing something outside of the current database.
Agreed, you should always know what your using. Plus with my original posting i didnt realise this was executing something outside of the current database.
Sure EvilPostIt:
Agree
good day
Agree
good day
ASKER
The Agent Job is owned by the SA.
should i not write WITH EXECUTE AS 'sa' ?