{"id":804,"date":"2015-06-03T14:31:23","date_gmt":"2015-06-03T08:31:23","guid":{"rendered":"http:\/\/dotnetsql.info\/net-sql\/?p=804"},"modified":"2015-06-29T16:48:32","modified_gmt":"2015-06-29T10:48:32","slug":"setup-sql-server-alerts-and-email","status":"publish","type":"post","link":"http:\/\/dotnetsql.info\/net-sql\/index.php\/setup-sql-server-alerts-and-email\/","title":{"rendered":"Setup SQL Server alerts and email"},"content":{"rendered":"<p><strong>Scenario<\/strong><\/p>\n<p>Setting up\u00a0an alert to e-mail an operator with a message is a multiple step process. You can setup database mail, define an operator and\u00a0an alert, but still no e-mail is\u00a0being sent. So how do you\u00a0send an alert to an operator?<\/p>\n<p><strong>Solution<\/strong><\/p>\n<p><em>This solution involves restarting SQL Agent. <\/em><!--more--><\/p>\n<p><strong>Database Mail <\/strong><\/p>\n<p>First setup database mail with a profile named SQLAlerts. The profile can be named anything but in these instructions, the profile name SQLAlerts is referenced. If you wish to use a different profile name just substitute accordingly.<\/p>\n<p><strong>Define Operator <\/strong><\/p>\n<p>Connect to the instance using Microsoft SQL Management Studio<\/p>\n<p>Double Click SQL Server Agent<\/p>\n<p>Right Click on Operators and select New Operator<\/p>\n<p>&nbsp;<br \/>\nSpecify an operator Name, E-mail name, and click OK<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Setup SQL Agent Settings <\/strong><\/p>\n<p><strong><em>Note:<\/em><\/strong><em> This\u00a0step is often overlooked when creating an alert for the first time. SQL Agent must be setup correctly for operators to receive an\u00a0alert e-mail. <\/em><\/p>\n<p>Right Click SQL Server Agent &gt; select Properties<\/p>\n<p>&nbsp;<\/p>\n<p>Select Alert System in the left pane<\/p>\n<ul>\n<li>Checkmark &gt; Enable mail profile<\/li>\n<li>Verify Mail system: Database Mail<\/li>\n<li>Verify Mail Profile: SQLAlerts<\/li>\n<li>Checkmark &gt; Include body of e-mail in the notification message<\/li>\n<li>Click OK.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Restart SQL Agent to activate settings. <\/strong><\/p>\n<p><strong><em>Warning:<\/em><\/strong><em> Restarting SQL Agent will cancel any executing jobs. <\/em><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Define Alert <\/strong><\/p>\n<p>This sample alert will send an email when TEMPDB database gets larger than 0 KB. This setting is set zero so the alert can be tested. Once verified, you will need to update its settings to a reasonable amount or disable it.<\/p>\n<p>Right Click Alerts and select New Alert<\/p>\n<p>&nbsp;<\/p>\n<p>On the General pane specify<\/p>\n<ul>\n<li>Name: TEMPDB Growing<\/li>\n<li>Type: SQL Server performance condition alert<\/li>\n<li>Object: SQLServer:Databases<\/li>\n<li>Counter: Data File(s) (KB)<\/li>\n<li>Instance: tempdb<\/li>\n<li>Alert if counter: rises above<\/li>\n<li>Value: 0<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>Click Response in left pane<\/p>\n<ul>\n<li>Checkmark &gt; Notify operators<\/li>\n<li>Checkmark &gt; E-mail for the operator<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>Click Options in left pane<\/p>\n<ul>\n<li>Checkmark &gt; Include alert error text in E-mail<\/li>\n<li>Delay between response: 2 minutes<\/li>\n<\/ul>\n<p>Click OK<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Verify Alert is Working <\/strong><\/p>\n<p>The operator should receive an e-mail if not see the troubleshooting section.<\/p>\n<p>Open the Alert. Click History in the left pane.<\/p>\n<p>The fields are updated\u00a0when the alert is triggered.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Stop the Test <\/strong><\/p>\n<p>To stop the Alert from being sent every two minutes, you have two options disable the alert or provide a more appropriate size and response times.<\/p>\n<p>To disable alert<\/p>\n<ul>\n<li>Click General in left pane and remove the checkmark from Enable and click OK<\/li>\n<li>OR<\/li>\n<li>Right click on Alert name and select Disable<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>To change the settings<\/p>\n<ul>\n<li>Click General in left pane<\/li>\n<li>Change value to value larger than existing TEMPDB database file save. The current file size is included in the e-mailed alert.<\/li>\n<li>Click Options in left pane<\/li>\n<li>Change response to 720 minutes which is 12 hours<\/li>\n<li>Click OK<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Troubleshooting <\/strong><\/p>\n<p>If the operator does not receive an e-mail<\/p>\n<ul>\n<li>Test database mail by sending a test e-mail to the operator&#8217;s e-mail address.<\/li>\n<li>Make sure you restarted SQL Agent and it is running.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Thanks for reading this article,<\/strong><\/p>\n<p><strong>Next steps :<\/strong><\/p>\n<ol>\n<li><strong>Share this with your colleagues because Sharing\u00a0 is Learning<\/strong><\/li>\n<li><strong>Comment below if you need any assistance<\/strong><\/li>\n<\/ol>\n<p style=\"text-align: right;\"><em><strong>Powered by <a href=\"http:\/\/www.codereview.co\">CodeReview &#8211; Let&#8217;s make it Better!<\/a><\/strong><\/em><\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-twitter\"><a rel=\"nofollow\" data-shared=\"sharing-twitter-804\" class=\"share-twitter sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/setup-sql-server-alerts-and-email\/?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\"><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on Twitter (Opens in new window)<\/span><\/a><\/li><li class=\"share-linkedin\"><a rel=\"nofollow\" data-shared=\"sharing-linkedin-804\" class=\"share-linkedin sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/setup-sql-server-alerts-and-email\/?share=linkedin\" target=\"_blank\" title=\"Click to share on LinkedIn\"><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on LinkedIn (Opens in new window)<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow\" data-shared=\"sharing-facebook-804\" class=\"share-facebook sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/setup-sql-server-alerts-and-email\/?share=facebook\" target=\"_blank\" title=\"Share on Facebook\"><span><\/span><span class=\"sharing-screen-reader-text\">Share on Facebook (Opens in new window)<\/span><\/a><\/li><li class=\"share-google-plus-1\"><a rel=\"nofollow\" data-shared=\"sharing-google-804\" class=\"share-google-plus-1 sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/setup-sql-server-alerts-and-email\/?share=google-plus-1\" target=\"_blank\" title=\"Click to share on Google+\"><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on Google+ (Opens in new window)<\/span><\/a><\/li><li class=\"share-pocket\"><a rel=\"nofollow\" data-shared=\"\" class=\"share-pocket sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/setup-sql-server-alerts-and-email\/?share=pocket\" target=\"_blank\" title=\"Click to share on Pocket\"><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on Pocket (Opens in new window)<\/span><\/a><\/li><li class=\"share-email\"><a rel=\"nofollow\" data-shared=\"\" class=\"share-email sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/setup-sql-server-alerts-and-email\/?share=email\" target=\"_blank\" title=\"Click to email this to a friend\"><span><\/span><span class=\"sharing-screen-reader-text\">Click to email this to a friend (Opens in new window)<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div><div class='sharedaddy sd-block sd-like jetpack-likes-widget-wrapper jetpack-likes-widget-unloaded' id='like-post-wrapper-76243027-804-69d7b5f42a536' data-src='\/\/widgets.wp.com\/likes\/#blog_id=76243027&amp;post_id=804&amp;origin=dotnetsql.info&amp;obj_id=76243027-804-69d7b5f42a536' data-name='like-post-frame-76243027-804-69d7b5f42a536'><h3 class='sd-title'>Like this:<\/h3><div class='likes-widget-placeholder post-likes-widget-placeholder' style='height:55px'><span class='button'><span>Like<\/span><\/span> <span class=\"loading\">Loading...<\/span><\/div><span class='sd-text-color'><\/span><a class='sd-link-color'><\/a><\/div>","protected":false},"excerpt":{"rendered":"<p>Scenario Setting up\u00a0an alert to e-mail an operator with a message is a multiple step process. You can setup database mail, define an operator and\u00a0an alert, but still no e-mail is\u00a0being sent. So how do you\u00a0send an alert to an operator? Solution This solution involves restarting SQL Agent.<\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-twitter\"><a rel=\"nofollow\" data-shared=\"sharing-twitter-804\" class=\"share-twitter sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/setup-sql-server-alerts-and-email\/?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\"><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on Twitter (Opens in new window)<\/span><\/a><\/li><li class=\"share-linkedin\"><a rel=\"nofollow\" data-shared=\"sharing-linkedin-804\" class=\"share-linkedin sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/setup-sql-server-alerts-and-email\/?share=linkedin\" target=\"_blank\" title=\"Click to share on LinkedIn\"><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on LinkedIn (Opens in new window)<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow\" data-shared=\"sharing-facebook-804\" class=\"share-facebook sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/setup-sql-server-alerts-and-email\/?share=facebook\" target=\"_blank\" title=\"Share on Facebook\"><span><\/span><span class=\"sharing-screen-reader-text\">Share on Facebook (Opens in new window)<\/span><\/a><\/li><li class=\"share-google-plus-1\"><a rel=\"nofollow\" data-shared=\"sharing-google-804\" class=\"share-google-plus-1 sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/setup-sql-server-alerts-and-email\/?share=google-plus-1\" target=\"_blank\" title=\"Click to share on Google+\"><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on Google+ (Opens in new window)<\/span><\/a><\/li><li class=\"share-pocket\"><a rel=\"nofollow\" data-shared=\"\" class=\"share-pocket sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/setup-sql-server-alerts-and-email\/?share=pocket\" target=\"_blank\" title=\"Click to share on Pocket\"><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on Pocket (Opens in new window)<\/span><\/a><\/li><li class=\"share-email\"><a rel=\"nofollow\" data-shared=\"\" class=\"share-email sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/setup-sql-server-alerts-and-email\/?share=email\" target=\"_blank\" title=\"Click to email this to a friend\"><span><\/span><span class=\"sharing-screen-reader-text\">Click to email this to a friend (Opens in new window)<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div><div class='sharedaddy sd-block sd-like jetpack-likes-widget-wrapper jetpack-likes-widget-unloaded' id='like-post-wrapper-76243027-804-69d7b5f42adcf' data-src='\/\/widgets.wp.com\/likes\/#blog_id=76243027&amp;post_id=804&amp;origin=dotnetsql.info&amp;obj_id=76243027-804-69d7b5f42adcf' data-name='like-post-frame-76243027-804-69d7b5f42adcf'><h3 class='sd-title'>Like this:<\/h3><div class='likes-widget-placeholder post-likes-widget-placeholder' style='height:55px'><span class='button'><span>Like<\/span><\/span> <span class=\"loading\">Loading...<\/span><\/div><span class='sd-text-color'><\/span><a class='sd-link-color'><\/a><\/div>","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[25],"tags":[250,251,97,217,40],"aioseo_notices":[],"_links":{"self":[{"href":"http:\/\/dotnetsql.info\/net-sql\/index.php\/wp-json\/wp\/v2\/posts\/804"}],"collection":[{"href":"http:\/\/dotnetsql.info\/net-sql\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/dotnetsql.info\/net-sql\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/dotnetsql.info\/net-sql\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/dotnetsql.info\/net-sql\/index.php\/wp-json\/wp\/v2\/comments?post=804"}],"version-history":[{"count":2,"href":"http:\/\/dotnetsql.info\/net-sql\/index.php\/wp-json\/wp\/v2\/posts\/804\/revisions"}],"predecessor-version":[{"id":937,"href":"http:\/\/dotnetsql.info\/net-sql\/index.php\/wp-json\/wp\/v2\/posts\/804\/revisions\/937"}],"wp:attachment":[{"href":"http:\/\/dotnetsql.info\/net-sql\/index.php\/wp-json\/wp\/v2\/media?parent=804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/dotnetsql.info\/net-sql\/index.php\/wp-json\/wp\/v2\/categories?post=804"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/dotnetsql.info\/net-sql\/index.php\/wp-json\/wp\/v2\/tags?post=804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}