[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 746
  • Last Modified:

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.
0
heyday2004
Asked:
heyday2004
1 Solution
 
bcsqlCommented:
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

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now