{"id":653,"date":"2009-02-16T14:54:00","date_gmt":"2009-02-16T14:54:00","guid":{"rendered":"\/blogs\/bobb\/post\/Watch-the-SqlNotificationInfo-for-query-notifications.aspx"},"modified":"2009-02-16T14:54:00","modified_gmt":"2009-02-16T14:54:00","slug":"watch-the-sqlnotificationinfo-for-query-notifications","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/bobb\/watch-the-sqlnotificationinfo-for-query-notifications\/","title":{"rendered":"Watch the SqlNotificationInfo for query notifications"},"content":{"rendered":"<p>\nI&#39;ve been back working with SQL Server Query Notifications again lately. This blog post stems from a problem where the query notification &quot;appears to register correctly&quot; but does not fire. Or registers but &quot;fires immediately&quot;. In this case &quot;register correctly&quot; meant fires a QN:Subscription event to SQL Profiler.\n<\/p>\n<p>\nThe firing of a QN:Subscription event to SQL Profiler means that you did attempt to register a query notification. The query notification can either register correctly or return an additional field in the QN:Subscription event, an XML attribute named &quot;info&quot;. This can be the reason why the Query Notification was NOT registered.\n<\/p>\n<p>\nIf your OnChange handler gets hit, you may either be getting a valid notification (some row has changed) or a notification that something has gone wrong, either with the registration or after the registration. Be sure and look at the SqlNotificationInfo for each request to see what happened.\n<\/p>\n<p>\nThe most common reason for a query notification to fail registration is &quot;Query&quot;, that is the query is not supported by Query Notifications. But the one that I ran into recently is &quot;Isolation&quot;. Query Notifications aren&#39;t supported if the statement that performs the SELECT is running under isolation level Read Uncommitted or Snapshot. Another interesting one that can happen at registration time is &quot;Options&quot;, the SET options aren&#39;t set properly (yes, Query Notifications require certain SET options).\n<\/p>\n<p>\nAfter the notification is registered, you can get not only Insert\/Update\/Delete notifications but also &quot;Alter, a table\/index\/view definition was altered. And, if the SQL Server is recycled while you have a pending Query Notification, you&#39;ll get a &quot;restart&quot; notification reason when it starts back up. Bear in mind that you won&#39;t get that restart&nbsp;notification if Mirroring-Based failover happens (see <a href=\"http:\/\/support.microsoft.com\/kb\/930048\" class=\"broken_link\">http:\/\/support.microsoft.com\/kb\/930048<\/a>).\n<\/p>\n<p>\nMost times you just want to invalidate your cache and re-register the query notification, but note the reason (SqlNotificationInfo class) carefully; reregistering a query that fails for &quot;Options&quot; or &quot;Isolation&quot; just causes a register-fire-reregister spin behavior. Or, if you only act on Insert\/Update\/Delete, the perception that the notification registers correctly but never fires.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#39;ve been back working with SQL Server Query Notifications again lately. This blog post stems from a problem where the query notification &quot;appears to register correctly&quot; but does not fire. Or registers but &quot;fires immediately&quot;. In this case &quot;register correctly&quot; meant fires a QN:Subscription event to SQL Profiler. The firing of a QN:Subscription event to [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[],"class_list":["post-653","post","type-post","status-publish","format-standard","hentry","category-query-notifications"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.9.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Watch the SqlNotificationInfo for query notifications - 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\/watch-the-sqlnotificationinfo-for-query-notifications\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Watch the SqlNotificationInfo for query notifications - Bob Beauchemin\" \/>\n<meta property=\"og:description\" content=\"I&#039;ve been back working with SQL Server Query Notifications again lately. This blog post stems from a problem where the query notification &quot;appears to register correctly&quot; but does not fire. Or registers but &quot;fires immediately&quot;. In this case &quot;register correctly&quot; meant fires a QN:Subscription event to SQL Profiler. The firing of a QN:Subscription event to [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/bobb\/watch-the-sqlnotificationinfo-for-query-notifications\/\" \/>\n<meta property=\"og:site_name\" content=\"Bob Beauchemin\" \/>\n<meta property=\"article:published_time\" content=\"2009-02-16T14:54: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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/watch-the-sqlnotificationinfo-for-query-notifications\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/watch-the-sqlnotificationinfo-for-query-notifications\/\",\"name\":\"Watch the SqlNotificationInfo for query notifications - Bob Beauchemin\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\"},\"datePublished\":\"2009-02-16T14:54:00+00:00\",\"dateModified\":\"2009-02-16T14:54:00+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/watch-the-sqlnotificationinfo-for-query-notifications\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/bobb\/watch-the-sqlnotificationinfo-for-query-notifications\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/watch-the-sqlnotificationinfo-for-query-notifications\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Query Notifications\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/query-notifications\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Watch the SqlNotificationInfo for query notifications\"}]},{\"@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":"Watch the SqlNotificationInfo for query notifications - 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\/watch-the-sqlnotificationinfo-for-query-notifications\/","og_locale":"en_US","og_type":"article","og_title":"Watch the SqlNotificationInfo for query notifications - Bob Beauchemin","og_description":"I&#39;ve been back working with SQL Server Query Notifications again lately. This blog post stems from a problem where the query notification &quot;appears to register correctly&quot; but does not fire. Or registers but &quot;fires immediately&quot;. In this case &quot;register correctly&quot; meant fires a QN:Subscription event to SQL Profiler. The firing of a QN:Subscription event to [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/watch-the-sqlnotificationinfo-for-query-notifications\/","og_site_name":"Bob Beauchemin","article_published_time":"2009-02-16T14:54:00+00:00","author":"Bob Beauchemin","twitter_misc":{"Written by":"Bob Beauchemin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/watch-the-sqlnotificationinfo-for-query-notifications\/","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/watch-the-sqlnotificationinfo-for-query-notifications\/","name":"Watch the SqlNotificationInfo for query notifications - Bob Beauchemin","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website"},"datePublished":"2009-02-16T14:54:00+00:00","dateModified":"2009-02-16T14:54:00+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/watch-the-sqlnotificationinfo-for-query-notifications\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/bobb\/watch-the-sqlnotificationinfo-for-query-notifications\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/watch-the-sqlnotificationinfo-for-query-notifications\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/"},{"@type":"ListItem","position":2,"name":"Query Notifications","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/query-notifications\/"},{"@type":"ListItem","position":3,"name":"Watch the SqlNotificationInfo for query notifications"}]},{"@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\/653","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=653"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/653\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/media?parent=653"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/categories?post=653"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/tags?post=653"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}