Sunday, September 28, 2014

1 How to fix “Msg 22003, Level 16, State 1, Line 33 StartService() returned error 5, 'Access is denied.'”

While try to stop the SQL agent through xp_servicecontrol, I get the Access is denied error “

Msg 22003, Level 16, State 1, Line 33
StartService() returned error 5, 'Access is denied

I am able to run “xp_servicecontrol 'querystate','SQLAgent$SGC4SQL2014'”



This is same error as if I login as same account as SQL Server account and try to stop the sql agent using sc command


However,SQLAgent is also running under this account. I can start/stop the sqlagent using the same account via SQL Server configuration manager but can not do it through command line.

Here are some of the testing I did

1. User belong to Administrator group: same error

2. Normal user: same error

3. Domain Admin: works

4. Local admin: works

Only granting the local admin to the user that is running under SQL server or Add that account to the domain admin.

Apparently, Domain admin is overkill and should be avoided. If this is the function you really need, try to grant the account local admin on the host.


  1. You really make it appear really easy along with your presentation but I to find this topic to be really something which I believe I would by no means understand. It sort of feels too complicated and extremely extensive for me. I’m taking a look ahead on your next publish, I¡¦ll attempt to get the cling of it!



SQL Panda Copyright © 2011 - |- Template created by O Pregador - |- Powered by Blogger Templates