How to check if SQL Server Agent is running

qinking126 picture qinking126 · Jul 24, 2012 · Viewed 48.5k times · Source

I am using SQL Server 2008 r2. I want to find a way to verify if SQL Server Agent is running. I am suspicious that the Agent isn't running, but I don't know how to check.

Answer

Aaron Bertrand picture Aaron Bertrand · Jul 24, 2012

In Management Studio, you can check if SQL Server Agent is running by looking at the SQL Server Agent node in Object Explorer. In the following screen shot, SQL Server Agent on my SQL Server 2012 instance is running (green arrow overlaid on the SQL Server Agent icon), but the agent for SQL Server 2000 is stopped (red x).

enter image description here

You can also check in Control Panel > Administrative Tools > Services:

enter image description here

Or in Program Files > Microsoft SQL Server > Configuration Tools > Configuration Manager:

enter image description here

Finally, you can check the state using T-SQL:

DECLARE @agent NVARCHAR(512);

SELECT @agent = COALESCE(N'SQLAgent$' + CONVERT(SYSNAME, SERVERPROPERTY('InstanceName')), 
  N'SQLServerAgent');

EXEC master.dbo.xp_servicecontrol 'QueryState', @agent;