SQL Server Agent
Not yet tested on a real installation — tell us how it went. The code follows the vendor's documentation. Write to support@taskbeacon.io.
T-SQL cannot call a URL, so the pings are their own job steps (CmdExec with curl.exe).
The code
This is the code the Code tab generates (with start and errors ticked). In the app it already contains your job's own address.
-- 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.How it works
Separate CmdExec steps ping /start before your T-SQL step, the plain address after it succeeds and /fail when it fails. Agent passes neither an exit code nor the error text to the ping, and no row count: the error itself is in the job's history in SQL Server.
Untick options on the Code tab to leave parts out. See what can be reported.
Run on a schedule
In SQL Server Management Studio: SQL Server Agent → Jobs → your job → Properties → Schedules → New. Pick daily, weekly or monthly and a time, and set the same schedule on the job in TaskBeacon. Add the steps above under Steps, in that order, with the On success / On failure actions as written.
Common problems
- You can't choose Operating system (CmdExec). By default only members of sysadmin can create CmdExec steps; others need a CmdExec proxy account (ask your DBA).
- The CmdExec step fails, the T-SQL step was fine. The step runs on the database server as the SQL Server Agent service account (or the proxy), not as you. That server must reach the TaskBeacon address over HTTPS; run the curl line there in a Command Prompt to see what blocks it.
- curl.exe not found. It is built into Windows Server 2019 and newer. On an older server, give the full path to a
curl.exeplaced there. - The alert has no error text. The fail step only says that the T-SQL step failed. The error itself is in SQL Server under the job's View History.
Use cases: SQL Server Agent job failure alerts without Database Mail. More questions: FAQ.