Stored procedure failed because of "WITH EXECUTE AS SELF" ?

I have a storec procedure, doing some kind of cross database queries, create temp tables, and populate data, etc. No problem. But when I added a line "WITH EXECUTE AS SELF", like below:

CREATE PROCEDURE [dbo].[cpTestProcedure]
WITH EXECUTE AS SELF
AS ...

The stored procedure failed (transaction rolled back). Could anyone let me know why it is like this and if it is good to add "WITH EXECUTE AS SELF" in every procedure? (I saw this format in some T-SQL template, so I assume it is a good programming style). Thanks.
heyday2004Asked:
Who is Participating?
 
bcsqlConnect With a Mentor Commented:
I depends on what context you want the code to execute in. This does a pretty good job of explaining it.

http://blogs.conchango.com/christianwade/archive/2004/11/02/156.aspx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.