PRB: SQLServerAgent Service May Stop Responding (hang) After You Restart the Computer (306655)
The information in this article applies to:
This article was previously published under Q306655 SYMPTOMS
Sometimes, after you restart a computer, the SQLServerAgent service may appear to stop responding (hang). If you run this command from a command prompt
NET START
you can see that the SQL Agent has not started, although it is set to automatic. If you open the Services applet in Control Panel and press the Startup button for the SQLServerAgent, this error message appears:
The service database is locked.
The error message also appears with other services if you click their Startup buttons.
CAUSE
The error message shown in the "Symptoms" may occur for several reasons one of which is if the SQLServerAgent service does not start after you restart the computer even though the service is set to automatic. If the error message occurs because the SQLServerAgent service is having difficulty starting, it is because the SQLServerAgent service is holding the service
control manager's database open until a failure or success occurs. Under normal circumstances, if the SQLServerAgent service starts, the database closes and the error message does not appear.
RESOLUTION
If you manually press the SQLServerAgent Start button, the service starts properly. However, this action does not satisfy the necessity for an automatic startup of the SQLServerAgent service. After the SQLServerAgent service starts, you can press the Start button on any other service with no additional problems.
To work around the problem, configure the SQLServerAgent service to startup automatically. To configure the SQLServerAgent service to startup automatically:
- Set the SQLServerAgent service startup to Manual.
- Create a startup stored procedure that invokes NET START for the SQLServerAgent service. For instance:
xp_cmdshell 'net start sqlserveragent'
With the preceding code, the SQLServerAgent service automatically starts every time SQL Server starts.
For example:
CREATE PROC StartSQLAgent
AS
EXEC master..xp_cmdshell 'net start sqlserveragent'
GO
EXEC sp_procoption 'StartSQLAgent', 'startup', 'on'
NOTE: Do not use this approach with a clustered SQL Server installation.
This approach does not deal with the underlying problem, it only provides a workaround.
STATUS
This behavior is by design.
Modification Type: | Major | Last Reviewed: | 7/1/2002 |
---|
Keywords: | kbprb KB306655 |
---|
|