SQL Server Agent
अभी किसी असली installation पर test नहीं किया गया — हमें बताएँ कि कैसा रहा। यह code vendor के documentation के अनुसार है। support@taskbeacon.io पर लिखें।
T-SQL किसी URL को call नहीं कर सकता, इसलिए pings अपने अलग job steps हैं (curl.exe के साथ CmdExec)।
Code
यह वह code है जो Code टैब बनाता है (start और errors पर निशान लगाकर)। App में इसमें पहले से आपके job का अपना पता होता है।
-- 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.यह कैसे काम करता है
अलग CmdExec steps आपके T-SQL step से पहले /start, उसके सफल होने के बाद सादा address और fail होने पर /fail ping करते हैं। Agent ping को न exit code देता है, न error text, न row count: error खुद SQL Server में job की history में है।
किसी हिस्से को छोड़ने के लिए Code टैब पर विकल्पों का निशान हटाएँ। देखें क्या रिपोर्ट किया जा सकता है।
Schedule पर चलाएँ
SQL Server Management Studio में: SQL Server Agent → Jobs → आपका job → Properties → Schedules → New। Daily, weekly या monthly और एक समय चुनें, और TaskBeacon में job पर वही schedule सेट करें। ऊपर दिए steps को Steps में उसी क्रम में जोड़ें, On success / On failure actions वैसे ही रखें जैसे लिखे हैं।
आम समस्याएँ
- आप Operating system (CmdExec) नहीं चुन पाते। Default रूप से केवल sysadmin के members CmdExec steps बना सकते हैं; बाक़ी लोगों को CmdExec proxy account चाहिए (अपने DBA से पूछें)।
- CmdExec step fail होता है, T-SQL step ठीक था। यह step database server पर SQL Server Agent service account (या proxy) के रूप में चलता है, आपके रूप में नहीं। उस server को HTTPS पर TaskBeacon के पते तक पहुँचना चाहिए; क्या चीज़ उसे रोक रही है, यह देखने के लिए वहीं Command Prompt में curl line चलाएँ।
- curl.exe नहीं मिला। यह Windows Server 2019 और नए में पहले से मौजूद है। पुराने server पर वहाँ रखी किसी
curl.exeका पूरा path दें। - Alert में कोई error text नहीं है। Fail step केवल इतना बताता है कि T-SQL step fail हुआ। Error ख़ुद SQL Server में job के View History में है।
उपयोग के उदाहरण: Database Mail के बिना SQL Server Agent job failure alerts। और सवाल: FAQ.