How to fix error "SQL Server Agent stopped automatically"?
Asked Answered
H

9

18

I'm using SQL Server 2014 and having a problem.

In Task Manager, on Services tab, I found SQLAgent$VILLBE_SQLSERVER (VILLBE is my computer name), right click and Start.

It started and... stopped after 1 second.

Then, I open services.msc, and Start the SQL Server Agent (VILLBE_SQLSERVER). It's working.

After 30 seconds, it stopped automatically. When I click Start again, it said that:

The SQL Server Agent (VILLBE_SQLSERVER) service on Local Computer started and then stopped. Some services stop automatically if they are not in use by other services or programs.

Last, I right click SQL Server Agent, choose Properties, set Start up type is Automatic and reboot my PC.

When reboot is done, SQL Server Agent still is stopped

Some other services:

SQL Server Browser - Running - Automatic (start up)

SQL Server (SQLEXPRESS) - Cannot start within warning: **Windows could not start the SQL Server (SQLEXPRESS) on Local Computer....error code 17058.**

Can you give me anyway to fix the problem?

Thank you!

Holophytic answered 28/3, 2015 at 14:5 Comment(1)
Can you look into the windows event log, it should give more information about why the server crashedStubstad
T
24

If you are running SQLEXPRESS, then SQLAGENT doesn't run. If you are running SQL2008 OR SQL2012, probably you changed SQL SA password. You can change SQL Service authentication from Network Service to Local System, then Start the service manually.

Travis answered 3/9, 2015 at 19:32 Comment(5)
What if this happens on a local machine without any network connection set up?Soteriology
"If you are running SQLEXPRESS, then SQLAGENT doesn't run." This is what helped me. My SQL Express was fine, Agent does not need to run.Linkwork
Express version does NOT support MSSQL Server AgentIveyivie
By checking log in C:\Program Files\Microsoft SQL Server\SERVER NAME\MSSQL\Log\SQLAGENT.OUT: The edition of SQL Server that installed this service does not support SQL Server Agent.Iveyivie
None of these comments are correct what so ever. I JUST installed SQL Express 2014 and Server Agent was running automatically... I stopped and tried to restart it now it won't run.Rudderhead
N
3

SQL Server Agent has to log on as Local System Account. Open up services console (start > run > type services.msc) and locate "SQL Server Agent" service and double click on it. Go to "Log On" tab and ensure "Local System Account" is selected. After confirming, you should be able to start this service. You can also use "net start SQLAgent$SQLEXPRESS" command.

Start, Stop, or Pause the SQL Server Agent Service

Noeminoesis answered 11/10, 2016 at 18:9 Comment(1)
This is not correct. SQL Server Agent can run under any valid service account, including local system, domain or local accounts.Silassilastic
B
3

This can be one of reason

1.Goto Sql Server Configration Manager

2.Click SQL Server Services from left panel

3.Right click SQL Server Agent From right panel and click properties

4.Goto service tab

5.Change start type automatic if it is set manuel

Boyt answered 31/12, 2018 at 6:28 Comment(1)
Mine was set to manual. I'll see if this fixes it.Scissile
T
3

Please check the account used to start the sql server agent. On the SSMS go to the "Object Explorer" and the search the account under "Security | logins". Please ensure that the SQL Server agent account as the correct permissions.

For example if you check the SQL Logs under "SQL Server Agent | Error Logs" you might see error messages like:

"Message [000] The EXECUTE permission was denied on the object 'sp_sqlagent_update_agent_xps', database 'msdb', schema 'dbo'. [SQLSTATE 42000] (Error 229)"

In this scenario giving execute permissions to the user will resolve the issue. Note that sql server standard roles do not included and "executor role". Hence you will need to create one or give a sysadmin role.

Example Sql Server Agent starts with "localsystem", provide sysadmin or executor role to Login "NT AUTHORITY\SYSTEM"

Triny answered 11/8, 2021 at 11:25 Comment(1)
In my case I had to go to the Object Explorer and browse to Security => Logins and add the Network Service as part of the login groups (the default one used in SQL Server 2017 for the SQL Server Agent). Yay! :DHomophonic
P
1

Make sure you are not using express edition, you can repair SQL server using setup.exe file it will fix your issue.

Pinochle answered 24/11, 2016 at 13:12 Comment(0)
G
1

I had to give the user running SQL Server Agent service Modify rights to its log:

C:\Program Files\Microsoft SQL Server\<SERVER NAME>\MSSQL.<INSTANCE NAME>\Log\SQLAGENT.OUT

But, I wasn't using SQL Express, either.

Gnomic answered 17/4, 2018 at 20:20 Comment(0)
E
0

Assuming that you are trying to schedule some SQL Server automation, before running out of solutions, registering one of your own user-defined stored procedures to be automatically executed whenever SQL Server instance is started may a usefull workaround for you, since you can write your onwn scheduling loop that may be kept running as long as your SQL Server service is up.

In that case, you should know that ALL SQL Server versions (including Express) offers a system stored procedure name sp_procoption which allows you to register a stored procedure for auto-start.

exec sp_procoption @ProcName = ['put your procedure name'], @OptionName = 'STARTUP', @OptionValue = [on|off]

For further reading, I would suggest checking Armando Prato's excellent article and this SQL Server Online Book

Hope it helps!

Exactitude answered 26/7, 2018 at 18:29 Comment(0)
T
0

If you've been through more than one upgrade, a previous upgrade gave you a SID that doesn't match for your SQLServerAgent account. (NT SERVICE\SQLSERVERAGENT). It is highly likely that the folder ./MSSQL/LOG contains files that the current SQLSERVERAGENT account does not have permission to read. I find that you modify the folder first, but then, either modify each of the latest files to have the permission, or perhaps, easier, just reboot.

Tupler answered 16/11, 2020 at 0:23 Comment(0)
S
0

As suggested by dvhh in the main question, you can look at the Event Viewer -> Windows Logs -> Application log. Under "SQLAgent$<databasename>", you may see an error. In the case of the database I was analyzing:

SQLServerAgent could not be started (reason: This installation of SQL Server Agent is disabled. The edition of SQL Server that installed this service does not support SQL Server Agent.).

Schematic answered 26/2, 2021 at 16:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.