Nakul, a dedicated member of the Gandhinagar SQL Server User Group, recently emailed me with a very interesting, but quick question. He asked me why the SQL Server Agent starts before SQL Server Engine does? He made the very valid point that as the SQL Server Engine is the core service, it should start first, and there is little point to running the SQL Server Agent without it.
Off the top of my head, I can offer the following quick reasons for this sequence:
- The SQL Server Engine does not only run jobs for SQL Server Engine itself. It also runs jobs for other core services like the SQL Server Analysis Service, Integration Service, Reporting Service etc.;
- The SQL Server Agent can run almost any kind of task that an Operating system can run. For example invoking any program or running shell scripts;
- The SQL Server Agent also starts jobs which are scheduled to run the second the SQL Server Engine starts, and for this reason it is needed; and
- Replication, mirroring and a few other tasks also depend on Agent Jobs.
These are the reasons that I have come up with so far. Can you think of any more? Let us have your views.
Reference : Pinal Dave (https://blog.sqlauthority.com)
16 Comments. Leave new
I think there is a flaw in the question? How come SQL agent will start if Sql database engine on the server is not running? SQL agent depends on the SQL database engine to be running.
Hi Pinal,
I’m a little confused – SQL Agent should be configured to have the Database Engine as a dependency, and so should not be able to be started without the Database Engine. In fact, if you try to start the SQL Agent service, the Database Engine will be started first.
What am I missing that Nakul and yourself are discussing?
Thanks,
Jim
Hi Pinal,
I feel that the SQL Server service is required for the SQL Server Agent service to work, since all of its information/meta data including that of the jobs are stored in the msdb database, which in turn requires the SQL Server service to be up. Maybe that’s why when we try to stop the SQL Server service, we are prompted with a notification stating that the Agent service will also stop. And when we start the Agent service the SQL Server service is also automatically started.
Therefore, I am a little doubtful as to Nakul’s question regarding when the SQL Server Agent service actually starts before the SQL Server service. Does it (Agent service) actually start before the SQL Server service?
Also, regarding some of your reasons regarding why Agent might be starting before: Even in those cases I feel that SQL Server is required because all the job information (for example, even if it maybe for Analysis Services) is stored within SQL Server.
Hi,
SQL Server Agent does NOT start before the Engine cause of the established dependency in SCM and the need to have MSDB started to get the information for the jobs to be executed. The job engine conssist of two parts, the service itself and a repository to get the data from. No repository, no execution.
If someone sees this inhis environment, the SQL Server Agent Service is either from a different instance or someone removed manually the dependency.
-Jens
can u please tell me. how to run the SQLServerAgent as default one…Even though i tried to start it manually. It was not starting.. Can u please help me to get out of this issue….
Really interesting information, and valuable
Actually, you can disable SQL Server Agent in the services menu, while still enable SQL Server Engine. I do this trick on my developer machine, because I rarely do things that require Agent to be running.
Umm, it doesn’t.
Just try restarting the SQL Database Engine through services and you’ll see that the Agent has to be shut down first before the database engine will restart. Or, just shutdown all SQL services and then try starting only the Agent – you will find that you can’t.
I’ve seen some really bad SQL information on this blog before, but this is the worst post I have seen. Someone really needs to re-evaluate your MVP credentials.
This is not possible if you check the design of the SQL Engine you will crearly noticed that SQL Server Agent depends on msdb database which will be available after SQL Server services starts.
When i restart my sql server it is asking me to restart my sql server agent also but my management studio is not showing the sql server agent as i wanted that to be run for a job also some of the menus like configure database mail is also not shown when i right click on the database mail option. Please i will be very kindful if you help me
Regards
Narayanan
@Narayanan Nagarajan.
Sql Server Agent service is dependent on SQL Server Service. If you restart SQL Server service, definitely it will ask you to restart SQL Server agent Service also. SQL Server Agent is part of SQL Server. That behavior is common. So don’t panic, what ever it is doing, it is correct.
Looks like you are using SQL Server Express Client tools not regular SQL Server Client tools.
SQL Server Express does not provide Database Mail Configuration Setup Interface, and You cant see SQL Server Agent, You have to use either SQL Server DEVELOPMENT/ WORKGROUP/ ENTERPRISE/STANDARD Edition Client tools.
Try downloading SQL Server Evaluation Edition ( Its free and works good for 6 Months, good for evaluating) and see if this answers all your question.
~ IM.
Hi Dave,
You should ask him to start the agent without starting the SQL server service. I belive he has just asked not done it practically.lathoug it seems impossible but R& D’s are always there.
Sanjeev
Hi,
I am facing a problem,I installed sql server 2008 R2 in windows server 2008, sql agent is not running and if I am trying start it manually it is stopping automatically..
Please give me some suggestion.
I have the same problem where the agent will not start. I then shut down the sqlserver service and start the agent first and they both start. Not what I expected. They are both running as the system user on a stand alone sqlserver2008 server. This is the only way I could get them both to start, but after a reboot the agent is not running again. Any advice?
**********************************************************************************************************************************************************************************************************************************************if you installed these editions (dev/enterprise/web/azure).these versions associated with db-enginee(mssqlserver) and sql-agent.
by defalut microsoft given some databses for different purposes .we have MSDB databse which is used to maintain the sqlserver-agent services(obs,schedules,alerts,operators) .
1.”sqlserver enginee” can run independently . i.e. without AGENT
2.”sql agent can’t run independently” because it associated with MSDB ,this msdb integrated with Database-Enginee(MSSQLSERVER)
3.if you start agent means it starts first MSSQLSERVER-SERVICE then STARTS AGENT-SERVICE
4.if you stop agent service …it can run independently ..it never stops MSSQLSERVER(DATABASE-ENGINE)
5.if both services are running . you want to stop MSSQLSERVER(database enginee) then it asks us to stop AGENT-SERVICE (YES/NO-POP-UP-WIZARD).
—->if we click on “YES” then it stopped AGENT-SERVICE and Stopped “MSSQLSERVSER-SERVER” then SSMS
—–>if you click “NO” ,NOTHING will takes place .
——————————————————————————————————————-
——————————————————————————————————————-
“sqlserver agent” runs as a separate service on each instance and it runs as a window service.
**********************************************************************************************************************************************************************************************************************************************if you installed these editions (dev/enterprise/web/azure).these versions associated with db-enginee(mssqlserver) and sql-agent. express edition creates agent service but not linked with ssms/”DATABASE-ENGINE”.
By default Microsoft given some database for different purposes .we have MSDB database which is used to maintain the sqlserver-agent services(obs,schedules,alerts,operators) .
1.”sqlserver engine” can run independently . i.e. without AGENT
2.”sql agent can’t run independently” because it associated with MSDB ,this msdb integrated with Database-Engine(MSSQLSERVER)
3.if you start agent means it starts first MSSQLSERVER-SERVICE then STARTS AGENT-SERVICE
4.if you stop agent service …it can run independently ..it never stops MSSQLSERVER(DATABASE-ENGINE)
5.if both services are running . you want to stop MSSQLSERVER(database enginee) then it asks us to stop AGENT-SERVICE (YES/NO-POP-UP-WIZARD).
—->if we click on “YES” then it stopped AGENT-SERVICE and Stopped “MSSQLSERVSER-SERVER” then SSMS
—–>if you click “NO” ,NOTHING will takes place .
——————————————————————————————————————-
——————————————————————————————————————-
“sqlserver agent” runs as a separate service on each instance and it runs as a window service.