{"id":863,"date":"2006-04-25T11:03:00","date_gmt":"2006-04-25T11:03:00","guid":{"rendered":"\/blogs\/bobb\/post\/Using-WMI-and-SQL-Agent-Alerts-(part-1).aspx"},"modified":"2006-04-25T11:03:00","modified_gmt":"2006-04-25T11:03:00","slug":"using-wmi-and-sql-agent-alerts-part-1","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-wmi-and-sql-agent-alerts-part-1\/","title":{"rendered":"Using WMI and SQL Agent Alerts (part 1)"},"content":{"rendered":"<p>\nLately I&#39;ve been working on using WMI events in conjunction with SQLAgent alerts and jobs to notify operators, queue up notifications for the DBA&#39;s resolution offline, and other uses. Setting up the alert and the job is fairly straightforward, where I stumbled at first is referencing WMI variables (and even knowing what variables were available) in the job that processes the WMI event. The varaibles are doc&#39;d in BOL in conjunction with event notifications, which is really what the WMI provider for Events uses underneath.\n<\/p>\n<p>\nYou use a WQL query that references the event to set up the WMI Alert, using &quot;SELECT * FROM &lt;my_event&gt;&quot; syntax (BOL example is SELECT * FROM DEADLOCK_EVENTS). And reference in job by using a WMI variable, like so:\n<\/p>\n<p>\n&#8212; BOL example<br \/>\nINSERT INTO DeadlockEvents(AlertTime, DeadlockGraph)<br \/>\n&nbsp; VALUES (getdate(), N&#39;&#39;$(WMI(TextData))&#39;&#39;&#39;)\n<\/p>\n<p>\nSo, when you set all this up, why doesn&#39;t it work? It always produces &quot;TextData not available&quot;. Hmmm&#8230;The &quot;magic switch&quot; to success is found under SQL Server Agent &quot;Properties&quot; menu entry under SSMS. You need to turn on (in the Alert System tab, at the bottom of the page) &quot;Replace tokens for all job responses to alerts&quot;. They aren&#39;t WMI variables, they are WMI tokens. Success!&nbsp;Took me a while to find that one&#8230;\n<\/p>\n<p>\nBut, in SP1 it &quot;breaks&quot; again. Sigh. More about this in next blog entry.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Lately I&#39;ve been working on using WMI events in conjunction with SQLAgent alerts and jobs to notify operators, queue up notifications for the DBA&#39;s resolution offline, and other uses. Setting up the alert and the job is fairly straightforward, where I stumbled at first is referencing WMI variables (and even knowing what variables were available) [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,28],"tags":[],"class_list":["post-863","post","type-post","status-publish","format-standard","hentry","category-event-notifications","category-sql-server-2005"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.9.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Using WMI and SQL Agent Alerts (part 1) - Bob Beauchemin<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-wmi-and-sql-agent-alerts-part-1\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using WMI and SQL Agent Alerts (part 1) - Bob Beauchemin\" \/>\n<meta property=\"og:description\" content=\"Lately I&#039;ve been working on using WMI events in conjunction with SQLAgent alerts and jobs to notify operators, queue up notifications for the DBA&#039;s resolution offline, and other uses. Setting up the alert and the job is fairly straightforward, where I stumbled at first is referencing WMI variables (and even knowing what variables were available) [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-wmi-and-sql-agent-alerts-part-1\/\" \/>\n<meta property=\"og:site_name\" content=\"Bob Beauchemin\" \/>\n<meta property=\"article:published_time\" content=\"2006-04-25T11:03:00+00:00\" \/>\n<meta name=\"author\" content=\"Bob Beauchemin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Bob Beauchemin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-wmi-and-sql-agent-alerts-part-1\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-wmi-and-sql-agent-alerts-part-1\/\",\"name\":\"Using WMI and SQL Agent Alerts (part 1) - Bob Beauchemin\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\"},\"datePublished\":\"2006-04-25T11:03:00+00:00\",\"dateModified\":\"2006-04-25T11:03:00+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-wmi-and-sql-agent-alerts-part-1\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-wmi-and-sql-agent-alerts-part-1\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-wmi-and-sql-agent-alerts-part-1\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Event Notifications\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/event-notifications\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Using WMI and SQL Agent Alerts (part 1)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\",\"name\":\"Bob Beauchemin\",\"description\":\"SQL Server Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\",\"name\":\"Bob Beauchemin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g\",\"caption\":\"Bob Beauchemin\"},\"sameAs\":[\"http:\/www.sqlskills.com\/blogs\/bobb\/\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/author\/bobb\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using WMI and SQL Agent Alerts (part 1) - Bob Beauchemin","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-wmi-and-sql-agent-alerts-part-1\/","og_locale":"en_US","og_type":"article","og_title":"Using WMI and SQL Agent Alerts (part 1) - Bob Beauchemin","og_description":"Lately I&#39;ve been working on using WMI events in conjunction with SQLAgent alerts and jobs to notify operators, queue up notifications for the DBA&#39;s resolution offline, and other uses. Setting up the alert and the job is fairly straightforward, where I stumbled at first is referencing WMI variables (and even knowing what variables were available) [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-wmi-and-sql-agent-alerts-part-1\/","og_site_name":"Bob Beauchemin","article_published_time":"2006-04-25T11:03:00+00:00","author":"Bob Beauchemin","twitter_misc":{"Written by":"Bob Beauchemin","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-wmi-and-sql-agent-alerts-part-1\/","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-wmi-and-sql-agent-alerts-part-1\/","name":"Using WMI and SQL Agent Alerts (part 1) - Bob Beauchemin","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website"},"datePublished":"2006-04-25T11:03:00+00:00","dateModified":"2006-04-25T11:03:00+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-wmi-and-sql-agent-alerts-part-1\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/bobb\/using-wmi-and-sql-agent-alerts-part-1\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-wmi-and-sql-agent-alerts-part-1\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/"},{"@type":"ListItem","position":2,"name":"Event Notifications","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/event-notifications\/"},{"@type":"ListItem","position":3,"name":"Using WMI and SQL Agent Alerts (part 1)"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/","name":"Bob Beauchemin","description":"SQL Server Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/bobb\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e","name":"Bob Beauchemin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g","caption":"Bob Beauchemin"},"sameAs":["http:\/www.sqlskills.com\/blogs\/bobb\/"],"url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/author\/bobb\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/863","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/comments?post=863"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/863\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/media?parent=863"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/categories?post=863"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/tags?post=863"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}