SQL Server Agent job failure alerts without Database Mail
You want to know when a SQL Server Agent job fails, but Database Mail isn't set up, the DBA won't open SMTP from the database server, or the alert should also reach Slack or Teams. Two extra job steps can do the same without Database Mail, and also catch jobs that didn't run.
What Agent's own notifications need
SQL Server Agent can email an operator when a job fails, but Microsoft's setup has several parts, all of which must be in place:
- Database Mail configured, with an account, a profile and an SMTP server that accepts mail from the database server.
- In SQL Server Agent's properties, under Alert System: enable the mail profile, choose Database Mail and the profile, then restart SQL Server Agent.
- An operator with an email address.
- On each job, under Notifications: E-mail the operator When the job fails.
Each step is reasonable, but together they are why many jobs end up without notifications. Mail can also stop quietly: in early 2026 Database Mail stopped sending after a SQL Server 2025 cumulative update until a fixed build was released (Microsoft Q&A). Agent notifications also can't tell you about a job that didn't run, for example because the Agent service was stopped, the server was patched at the wrong hour, or the schedule was disabled. And SQL Server Express has no SQL Server Agent at all; there, jobs run from Task Scheduler (see email when a scheduled task fails).
Two extra job steps
T-SQL can't call a web address, so the pings are job steps of their own, of type Operating system (CmdExec), around your T-SQL step. The step flow sends the success ping after your step succeeds and the failure ping after it fails:
-- SQL Server Agent: T-SQL cannot call a URL, so add job steps around your T-SQL step.
-- curl.exe is built into Windows Server 2019+ and Windows 10/11. Step type: Operating system (CmdExec).
--
-- Step 1 "TaskBeacon start" Type: Operating system (CmdExec)
-- curl.exe -fsS -m 10 "https://taskbeacon.io/ping/your-job-id/start"
-- On success: Go to the next step. On failure: Go to the next step.
--
-- Step 2 "Your T-SQL" Type: Transact-SQL script (T-SQL)
-- EXEC dbo.your_procedure;
-- On success: Go to step 3. On failure: Go to step 4.
--
-- Step 3 "TaskBeacon success" Type: Operating system (CmdExec)
-- curl.exe -fsS -m 10 "https://taskbeacon.io/ping/your-job-id"
-- On success: Quit the job reporting success.
--
-- Step 4 "TaskBeacon fail" Type: Operating system (CmdExec)
-- curl.exe -fsS -m 10 "https://taskbeacon.io/ping/your-job-id/fail"
-- On success: Quit the job reporting failure. On failure: Quit the job reporting failure.Not yet tested on a real installation — tell us how it went. The code follows the vendor's documentation. Write to support@taskbeacon.io.
In the app, the Code tab of your job gives you this code with the job's own address instead of your-job-id, and you can untick the parts you don't need.
The steps use curl.exe, which Microsoft ships with Windows 10 and 11; on a server, check with curl.exe --version. If it is missing, the same step can run powershell.exe -NoProfile -Command "Invoke-WebRequest -UseBasicParsing -Uri '…'" instead. By default only members of sysadmin can create CmdExec steps (or users with a proxy account), and they run as the SQL Server Agent service account, which needs outbound HTTPS to one address.
Set the job's schedule in TaskBeacon the same as in Agent, so a run that didn't happen shows as Missed.
What you get
- Failed when your T-SQL step fails, by email, Slack, Teams or a webhook, to as many people as you like, without Database Mail.
- Missed when the job didn't report by its planned time plus grace: Agent stopped, schedule disabled, server down.
- Late when the job started and runs much longer than usual, such as a step waiting on a lock.
To catch a procedure that "succeeds" but moves no rows, make the success step send the count with ?rows= (for example a PowerShell step that runs the count query and then calls the address), and the usual row rules apply; see 0 rows or far fewer than usual.
Without TaskBeacon
Set up Database Mail and an operator as above; it is the built-in way and works well once it is there. For jobs that may not run at all, add a separate Agent job, or a check from another server, that queries msdb.dbo.sysjobhistory each morning and raises an alert when a job has no successful run in the expected window. Keep in mind that this check runs on the same Agent it is meant to watch.
Connected Claude or ChatGPT to TaskBeacon? Ask it "what failed last night, and why?" and it answers from your jobs. How that works.
Related
In the Docs: SQL Server Agent · Alerts · Schedules.
- Task Scheduler can't send email any more: get an alert when a task failsThe built-in e-mail action is gone; event-triggered tasks miss runs that never happened.
- Get an alert when a job loads 0 rows, or far fewer than usualExit code 0 says nothing about how many rows arrived.
- Find out when a scheduled job didn't run at allA run that never happened leaves no error to alert on.
TaskBeacon is free to start, with every feature open for now and no credit card. Create a job, paste the code, and the first ping shows up on the job page.
Start free View live demoSources
- Microsoft Learn: Configure SQL Server Agent Mail to use Database Mail (2025-05-16)
- Microsoft Learn: Notify an operator of job status (2025-09-07)
- Microsoft Learn: Editions and supported features of SQL Server 2025 (Express: no SQL Server Agent) (2025-11-19)
- Microsoft Learn: Create a CmdExec job step (2017, updated 2026-10-14)
- Microsoft Q&A: Database Mail stops working on SQL Server 2025 after CU1 (2026)
- curl.se: curl shipped by Microsoft (curl.exe in Windows 10 and 11) (undated; checked 2026-11-09)
Page checked against its sources on 2026-11-09. Menus and limits of other products change; if something here no longer matches, write to support@taskbeacon.io.