Share via


In a Job, Set Up Run As for Type Transact SQL Script

Question

Tuesday, March 4, 2014 10:17 PM

Hi,

In SQL Server 2012 Enterprise Edition I have a job with a step that runs T-SQL code. It is a step Type: Transact-SQL script (T-SQL).

I want to set up a "Run as:" for this job but it doesn't show up under proxies. Is this not possible? Does every Transact-SQL script have to run with the Agent's account?

Thank you

g

All replies (2)

Wednesday, March 5, 2014 7:07 AM ✅Answered

TSQL step is different from all other steps. All other steps mean Agent starts a OS process, and the Run as specifies whcih Agent Proxy to use. Agent Proxy points to a Credential, which points to a Windows account. This is why Run as isn't applicable for TSQL jobsteps. 

However, on the Advanced page for TSQL, you have a Run as user option where you can specify what username (not login) to run as. Another option is to add EXECUTE AS LOGIN = loginname as the first TSQL code for the job step.

Tibor Karaszi, SQL Server MVP | web | blog


Wednesday, March 5, 2014 8:24 AM ✅Answered

see below link for the option.

http://sqlmag.com/blog/semi-advanced-logging-options-sql-server-agent-jobs

Please Mark This As Answer if it helps to solve the issue Visakh http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs