简体   繁体   中英

T-SQL Server Agent Job fails “User does not have permission to perform this action”

I have setup a T-SQL job in the SQL Server Agent to run weekly. Within SQL Server Management Studio I am able to run the script successfully as a query but when the job runs it errors out saying:

“Executed as user: DOMAIN\\user. User does not have permission to perform this action. [SQLSTATE 42000] (Error 15247). The step failed.”

The script is exporting table data from one SQL server and dumping it into another linked server. From what I gathered T-SQL doesn't use proxies and credentials, it uses the owners login when performing the script I am db_owner on both databases and sysadmin and serveradmin on both servers, what am I missing?

Please see this page about security requirments on the server end (not database security) for the SQL Server Agent user context. SQL Agent is an external process that is assigned a Windows account to run under, and that account must be in the sysadmin group on the database instance, among other things.

Thanks everyone for the help, you suggestions guided me to a solution. To get it to work I my domain login is the the owner of the Job. In the step properties under advanced I left the Run as user blank and then added "EXEC AS LOGIN = 'DOMAIN\\user\u0026#39;" to the T-SQL script and it worked!

This is an old question but it's taken me forever to find an answer, so just to help reinforce it in case anybody else runs into this problem...

Chad's solution is the only solution that worked for me as well. Leave the 'Run as user' box in the job step properties advanced tab blank and add "EXEC AS LOGIN = 'DOMAIN\\user\u0026#39;" to the T-SQL script. I also had to make sure 'DOMAIN\\user\u0026#39; account had been added to SQL Server instance as a login with valid/necessary roles.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM