Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions Links


SQL Server DBA Jobs

How can I execute t-sql with a Proxy account

03 August,2021 by Tom Collins

Question: I have some t-sql code added to a job step on a SQL Server Agent job. The problem is I need to run the code as RUNAS . I though of executing the job with a proxy account - so progressed with the Credential & proxy set up.    But I still can't view the Proxy\Credential in the RunAs list . Is there a way around this problem?


Answer:    This is by design - you can't assign a proxy account to a t-sql step. The "standard" workarounds are 

1) Use powershell to manage the t-sql execute. This requires assigning the Proxy account to a Powershell Proxy

2)Use sqlcmd to execute the code - this requires creating an operating system proxy 


Read more 

Xp_cmdshell – the most dangerous extended stored procedure on the planet

How to script CREDENTIALS for SQL Server migration

Author: Tom Collins (


Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.


Post a comment on How can I execute t-sql with a Proxy account | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer