Search code examples
sql-serversql-server-2005permissions

Execute a stored procedure as another user


I have the following problem: there's a user, A, who has to execute a stored procedure (spTest). In spTest's body, sp_trace_generateevent is called.

The problem is that sp_trace_generateevent requires alter trace permissions, and I don't want user A to have those permissions. I would still like user A to be able to execute spTest. How can I do that?


Solution

  • Try this:

    EXECUTE AS user = 'special_user'
    
    EXECUTE YourProcerdure
    
    REVERT
    

    See these links for more information: