SQL SERVER – Reason for SQL Server Agent Starting Before SQL Server Engine Service

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 (http://blog.SQLAuthority.com)

About these ads

14 thoughts on “SQL SERVER – Reason for SQL Server Agent Starting Before SQL Server Engine Service

  1. 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.

  2. 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

  3. 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.

  4. 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….

  5. 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.

  6. 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.

  7. 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.

  8. 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

  9. @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.

  10. 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

  11. 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?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s