Quantcast
Channel: SQL Archives - SQL Authority with Pinal Dave
Viewing all articles
Browse latest Browse all 594

SQL SERVER – Unable to Start Service SQLSERVERAGENT on Server (mscorlib)

$
0
0

There are several reasons for the error mentioned in the blog title. In this blog, we would learn about one of the causes of error Unable to start service SQLSERVERAGENT on a server.

When my client contacted me, they were in process of changing the hardware/drives and the path of SQL Server related files. After making changes to the path of SQLAgent.OUT file, they were unable to start SQL Server Agent Service. Here is the screenshot when they tried starting SQL Server Agent service via SQL Server Management Studio.

SQL SERVER - Unable to Start Service SQLSERVERAGENT on Server (mscorlib) sqlagt-stop-01

Here is the text of the above error message.

Unable to start service SQLSERVERAGENT on server ABCLProdSQLServer. (mscorlib)

When I joined the call with them, I checked the event log, I found below message.

Failed to initialize SQL Agent log (reason: Access is denied).

From above, we can say that SQL Server Agent is trying to write to a log file but unable to do so. Now, we needed to find out the location and file name. Below is the T-SQL code to get the location.

USE [msdb]
GO
EXEC sp_configure 'Agent XPs', 1
GO
RECONFIGURE WITH OVERRIDE
GO
EXEC msdb.dbo.sp_get_sqlagent_properties -- CHECK FOR errorlog_file column

Check for an errorlog_file column. When I checked the value for my client, it was

H:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\Log

Above file was not getting generated due to an error in event log. Wait a second. Look closely, looks like my client missed SQLAgent.OUT file name over there. We already have a FOLDER called LOG and that’s why we can’t take a file with the same name.

WORKAROUND/SOLUTION

Now, since we have found that this was due to an incorrect value set for the SQL Server Agent log file, we need to correct the value. There are multiple ways to do it.

  1. Use below T-SQL
USE [msdb]
GO
EXEC sp_configure 'Agent XPs', 1
GO
EXEC msdb.dbo.sp_set_sqlagent_properties @errorlog_file=N'H:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\Log\SQLAgent.out'
GO
  1. We can also modify the registry directly using “Start > Run > Regedit” and navigating to the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQLSERVER\SQLServerAgent

Highlighted piece is the combination of the SQL version and instance name. MSSQL13 stands for SQL Server 2016. MSSQL12 is for SQL Server 2014 and so on and so forth.

We need to change a value for “ErrorLogFile” and provide a valid file name.

Once we made above changes, SQL Server Agent got started without any further error.

Reference: Pinal Dave (https://blog.sqlauthority.com)

First appeared on SQL SERVER – Unable to Start Service SQLSERVERAGENT on Server (mscorlib)


Viewing all articles
Browse latest Browse all 594

Trending Articles