Running TSQL as another user in SSMS

  • How can I run TSQL script as another user in SSMS to simulate that user's result and view the effect of their permissions?

  • Check out the EXECUTE AS command in Books On Line. Here is a sample from BOL.

    CREATE PROCEDURE dbo.usp_Demo

    WITH EXECUTE AS 'SqlUser1'

    AS

    SELECT user_name(); -- Shows execution context is set to SqlUser1.

    EXECUTE AS CALLER;

    SELECT user_name(); -- Shows execution context is set to SqlUser2, the caller of the module.

    REVERT;

    SELECT user_name(); -- Shows execution context is set to SqlUser1.

    GO

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • Thanks.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply