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