- Error number
- 22022
- Severity
- 16 (user-correctable error)
- State
- 1
- Product
- Microsoft SQL Server Database Engine
- Versions
- SQL Server editions that include SQL Server Agent (2016 to 2025, not Express), Azure SQL Managed Instance
- Category
- SQL Server Agent
- Last reviewed
- 23 October 2026
On this page
What it means
Error 22022 means you asked msdb to start a job (or otherwise notify SQL Server Agent) while the SQL Server Agent service was not running, so nothing happened.
Job procedures in msdb store their changes in tables and then notify the SQL Server Agent service. When the service is stopped, the notification fails and SQL Server sends this text. For sp_start_job it arrives as an error at level 16 and the job does not start; for procedures that only change job definitions (sp_add_jobserver, sp_update_job, sp_delete_job) it arrives as an informational message and the change is saved anyway, so Agent picks it up when it next starts.
Two details confuse people. The number 22022 is not the message stored in sys.messages: there 22022 is an unrelated internal file error, because this text is raised by the Agent notification extended procedure rather than from the catalogue. And because it comes from an extended procedure, TRY...CATCH does not catch it and @@ERROR stays 0; check the return code of sp_start_job instead (it returned 1 in our test).
Common causes
- The SQL Server Agent service is stopped, for example after a server restart when its start mode is Manual or Disabled.
- SQL Server Agent failed to start or stopped on its own, for example because its service account password changed or the account lost rights.
- The edition does not support SQL Server Agent: SQL Server Express cannot run Agent jobs.
- A script, application or deployment pipeline starts a job straight after a restart, before anyone has started Agent.
Diagnose it
Read-only These queries only read metadata and dynamic management views. They do not change data, permissions or configuration, so they are safe to run first.
Is SQL Server Agent running, and how does it start?
SELECT servicename, status_desc, startup_type_desc, service_account
FROM sys.dm_server_services
WHERE servicename LIKE N'SQL Server Agent%'; status_desc should be Running. Stopped with startup_type_desc of Manual or Disabled explains why the error returns after every restart.
Is there an Agent process connected to the instance?
SELECT session_id, program_name, login_name, login_time
FROM sys.dm_exec_sessions
WHERE program_name LIKE N'SQLAgent%'; No rows means Agent is not connected. When it runs you see sessions named SQLAgent - Generic Refresher, SQLAgent - Job invocation engine and similar.
Which edition is this?
SELECT SERVERPROPERTY('Edition') AS edition, SERVERPROPERTY('ProductVersion') AS version; On an Express edition SQL Server Agent cannot run jobs; use Windows Task Scheduler or another scheduler with sqlcmd instead.
Did the job ever start?
SELECT TOP (20) j.name, a.start_execution_date, a.stop_execution_date, a.run_requested_source
FROM msdb.dbo.sysjobactivity AS a
JOIN msdb.dbo.sysjobs AS j ON j.job_id = a.job_id
ORDER BY a.run_requested_date DESC; A job started while Agent was down has no new activity row. After you start Agent, run it again and check this list or the job history.
How to fix it
Each fix is labelled with what it changes. Try read-only checks and the least invasive fix first, and test changes outside production.
Start the SQL Server Agent service
Changes configurationStart SQL Server Agent (MSSQLSERVER), or SQLAgent$InstanceName for a named instance, from SQL Server Configuration Manager or from Object Explorer in SSMS (right-click SQL Server Agent, Start). Then run sp_start_job again.
-- PowerShell, run as an administrator on the server (default instance)
Start-Service -Name SQLSERVERAGENT
Set Agent to start automatically
Changes configurationIf the error comes back after each reboot, set the start mode of SQL Server Agent to Automatic in SQL Server Configuration Manager. If Agent will not start, read its log (SQLAGENT.OUT in the instance log folder) and the Windows event log; a changed service account password is a common reason.
Check the return code in scripts that start jobs
Client or network sideBecause TRY...CATCH does not see this error, test the return value of sp_start_job (0 means success) and stop or alert when it is not 0.
DECLARE @rc int;
EXEC @rc = msdb.dbo.sp_start_job @job_name = N'Nightly ETL';
IF @rc <> 0
THROW 50001, N'Nightly ETL did not start. Is SQL Server Agent running?', 1;
Examples
Starting a job while SQL Server Agent is stopped
Reproduced on SQL Server 2025 (17.0.1145.4) with SQL Server Agent stopped, using a temporary job that was deleted afterwards; the job name is changed here. SSMS and .NET SqlClient report Line 0; sqlcmd prints the same error as HResult 0x5606, Level 16, State 1. The procedure returned 1, @@ERROR was 0 and TRY...CATCH did not catch it.
EXEC msdb.dbo.sp_start_job @job_name = N'Nightly ETL';
Msg 22022, Level 16, State 1, Line 0 SQLServerAgent is not currently running so it cannot be notified of this action.
How to prevent it
Set SQL Server Agent to start automatically on every server that runs jobs, and include it in post-patching and post-restart checks. Monitoring sys.dm_server_services for a stopped Agent catches the problem before a scheduled job is missed, because when Agent is down no schedules run at all, and nothing reports it.
In deployment or ETL scripts that start jobs, check the return code of sp_start_job rather than relying on error handling.
Common questions
Why does sys.messages show a different text for error 22022?
The Agent notification message is sent by an extended stored procedure with its own text, not looked up in sys.messages. In the catalogue, 22022 belongs to an unrelated internal error, so searching sys.messages will not explain this message.
Was my job change saved even though I saw this message?
Yes, for procedures such as sp_add_jobserver, sp_update_job and sp_delete_job the message is informational and the change is stored in msdb. Only sp_start_job fails: the job did not run.
Can I run SQL Server Agent jobs on SQL Server Express?
No. Express does not run SQL Server Agent jobs. Schedule sqlcmd scripts with Windows Task Scheduler or another scheduler instead.
Learn more on CodeWithSQL
Official documentation
Last technically reviewed 23 October 2026; examples and diagnostics run on SQL Server 2025 (17.0.1145.4). Message text checked against the engine's sys.messages catalogue.