More things I learned today: EXEC AS USER on dynamic SQL
I really liked the addition of the WITH EXECUTE AS clause when defining stored procedures and functions, to change the execution context, just for the duration of the stored procedure or function. For example:
CREATE PROC SomeSchema.SomeProc
WITH EXECUTE AS USER = ‘Fred’
AS
…
I’d also used the EXEC AS clause to temporarily change my execution context during testing. For example:
EXEC AS USER = ‘Fred’;
-- Try some code here while running as Fred
2011-08-13