{"id":13303,"date":"2019-10-24T08:54:02","date_gmt":"2019-10-24T08:54:02","guid":{"rendered":"https:\/\/dbtut.com\/?p=13303"},"modified":"2019-10-24T08:55:12","modified_gmt":"2019-10-24T08:55:12","slug":"sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing","status":"publish","type":"post","link":"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/","title":{"rendered":"SQL Server Database Mail History Cleanup and Prevent msdb Database From Growing"},"content":{"rendered":"<p>If you are using SQL Server Database Mail, your msdb database can grow undesirably. We can use the msdb.dbo.sysmail_delete_mailitems_sp procedure to clear Database Mail History.<\/p>\n<h1>Query Database Mail History<\/h1>\n<p>We can see the database mail history with the help of the script below.<\/p>\n<pre class=\"lang:default decode:true\">select * from msdb..sysmail_allitems<\/pre>\n<h1>Database Mail History Cleanup<\/h1>\n<p>There are two procedure to cleanup database mail history.<\/p>\n<ul>\n<li>sysmail_delete_mailitems_sp<\/li>\n<li>sysmail_delete_log_sp<\/li>\n<\/ul>\n<h2>sysmail_delete_mailitems_sp<\/h2>\n<p>You can delete database mail messages by using this system stored procedure.<\/p>\n<h3>Delete All Mail Messages<\/h3>\n<pre class=\"lang:default decode:true\">EXEC msdb.dbo.sysmail_delete_mailitems_sp<\/pre>\n<h3>Delete Mail Messages Before a Certain Date<\/h3>\n<pre class=\"lang:default decode:true\">EXEC msdb.dbo.sysmail_delete_mailitems_sp @sent_before =  '2019-01-01'<\/pre>\n<h3>Delete Mail Messages With a Certains Status<\/h3>\n<pre class=\"lang:default decode:true\"><span class=\"com\">--<span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">You can also use unsent, retrying, failed instead of sent.<\/span><\/span><\/span>\nEXEC msdb.dbo.sysmail_delete_mailitems_sp  @sent_status = 'sent'<\/pre>\n<div class=\"tlid-input input\">\n<div class=\"source-wrap\">\n<div class=\"input-full-height-wrapper tlid-input-full-height-wrapper\">\n<div class=\"source-input\">\n<div class=\"source-footer-wrap source-or-target-footer\">\n<div class=\"source-footer\">\n<div class=\"speech-wrap source-or-target-footer-button left-positioned\">\n<h3 id=\"gt-speech\" class=\"speech-button goog-toolbar-button\" role=\"button\" aria-label=\"Ses giri\u015fini a\u00e7\" data-tooltip-align=\"t,c\" data-tooltip=\"Ses giri\u015fini a\u00e7\">Delete Mail Messages Before a Certain Date and With a Certain Status<\/h3>\n<\/div>\n<div class=\"src-tts left-positioned ttsbutton jfk-button-flat source-or-target-footer-button jfk-button\" role=\"button\" aria-label=\"Dinleyin\" data-tooltip=\"Dinleyin\" data-tooltip-align=\"t,c\" aria-hidden=\"false\">\n<div class=\"jfk-button-img\">\n<pre class=\"lang:default decode:true\"><span class=\"com\">--<span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">You can also use unsent, retrying, failed instead of sent.<\/span><\/span><\/span>\nEXEC msdb.dbo.sysmail_delete_mailitems_sp @sent_before =  '2019-01-01', @sent_status = 'sent'<\/pre>\n<h2>sysmail_delete_log_sp<\/h2>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"tlid-results-container results-container\">\n<div class=\"tlid-result result-dict-wrapper\">\n<div class=\"result tlid-copy-target\">\n<div class=\"result-header\">\n<div class=\"starbutton jfk-button-flat jfk-button unstarred\" role=\"button\" aria-label=\"\u00c7eviriye y\u0131ld\u0131z ekle\" data-tooltip=\"\u00c7eviriye y\u0131ld\u0131z ekle\" data-tooltip-align=\"t,c\">\n<div class=\"jfk-button-img\">You can delete database mail logs by using this system stored procedure.<\/div>\n<\/div>\n<\/div>\n<div class=\"text-wrap tlid-copy-target\">\n<div class=\"result-shield-container tlid-copy-target\">\n<h3>Delete All Mail Logs<\/h3>\n<pre class=\"lang:default decode:true\">EXEC msdb.dbo.sysmail_delete_log_sp<\/pre>\n<h3>Delete Mail Logs Before a Certain Date<\/h3>\n<pre class=\"lang:default decode:true\">EXEC msdb.dbo.sysmail_delete_log_sp @logged_before = '2019-01-01'<\/pre>\n<h3>Delete Mail Logs With a Certains Event Type<\/h3>\n<pre class=\"lang:default decode:true\"><span class=\"com\">--<span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">You can also use <\/span><\/span><\/span><span class=\"com\">warning, error, informational <\/span><span class=\"com\"><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">instead of sent.<\/span><\/span><\/span> \nEXEC msdb.dbo.sysmail_delete_log_sp @event_type = 'success'<\/pre>\n<div class=\"tlid-input input\">\n<div class=\"source-wrap\">\n<div class=\"input-full-height-wrapper tlid-input-full-height-wrapper\">\n<div class=\"source-input\">\n<div class=\"source-footer-wrap source-or-target-footer\">\n<div class=\"source-footer\">\n<div class=\"speech-wrap source-or-target-footer-button left-positioned\">\n<h3 id=\"gt-speech\" class=\"speech-button goog-toolbar-button\" role=\"button\" aria-label=\"Ses giri\u015fini a\u00e7\" data-tooltip-align=\"t,c\" data-tooltip=\"Ses giri\u015fini a\u00e7\">Delete Mail Logs Before a Certain Date and With a Certain Event Type<\/h3>\n<\/div>\n<div class=\"src-tts left-positioned ttsbutton jfk-button-flat source-or-target-footer-button jfk-button\" role=\"button\" aria-label=\"Dinleyin\" data-tooltip=\"Dinleyin\" data-tooltip-align=\"t,c\" aria-hidden=\"false\">\n<div class=\"jfk-button-img\">\n<pre class=\"lang:default decode:true \"><span class=\"com\">--<span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">You can also use unsent, retrying, failed instead of sent.<\/span><\/span><\/span>\nEXEC msdb.dbo.sysmail_delete_log_sp @logged_before = '2019-01-01', @event_type = 'success'<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_13303\" class=\"pvc_stats all  \" data-element-id=\"13303\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dbtut.com\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>If you are using SQL Server Database Mail, your msdb database can grow undesirably. We can use the msdb.dbo.sysmail_delete_mailitems_sp procedure to clear Database Mail History. Query Database Mail History We can see the database mail history with the help of the script below. select * from msdb..sysmail_allitems Database Mail History Cleanup There are two procedure &hellip;<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_13303\" class=\"pvc_stats all  \" data-element-id=\"13303\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dbtut.com\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":366,"featured_media":13304,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[3],"tags":[670,4985,4984,4983,4999,4987,4998,4988,5001,5005,5003,4989,4992,4990,5000,5004,4986,5002,4993,4991,4995,4994,5006,4996,4997,4982,4981],"class_list":["post-13303","post","type-post","status-publish","format-standard","has-post-thumbnail","","category-mssql","tag-after-delete","tag-clean-database-mail-history","tag-clean-mail-history","tag-database-mail-history-cleanup","tag-delete-all-database-mail-logs","tag-delete-all-database-mail-messages","tag-delete-all-mail-logs","tag-delete-all-mail-messages","tag-delete-database-mail-logs-before-a-certain-date","tag-delete-database-mail-logs-before-a-certain-date-and-with-a-certain-event-type","tag-delete-database-mail-logs-with-a-certains-event-type","tag-delete-database-mail-messages-before-a-certain-date","tag-delete-database-mail-messages-before-a-certain-date-and-with-a-certain-status","tag-delete-database-mail-messages-with-a-certains-status","tag-delete-mail-logs-before-a-certain-date","tag-delete-mail-logs-before-a-certain-date-and-with-a-certain-event-type","tag-delete-mail-logs-sql-server","tag-delete-mail-logs-with-a-certains-event-type","tag-delete-mail-messages-before-a-certain-date-and-with-a-certain-status","tag-delete-mail-messages-with-a-certains-status","tag-msdb-growing-too-big-due-to-database-mail","tag-msdb-is-too-big-due-to-database-mail-log","tag-prevent-msdb-database-from-growing","tag-removing-database-mail-history-in-sql-server","tag-removing-sql-database-mail-history","tag-sysmail_delete_log_sp","tag-sysmail_delete_mailitems_sp"],"aioseo_notices":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>SQL Server Database Mail History Cleanup and Prevent msdb Database From Growing - Database Tutorials<\/title>\n<meta name=\"description\" content=\"SQL Server Database Mail History Cleanup and prevent msdb database from growing\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Server Database Mail History Cleanup and Prevent msdb Database From Growing - Database Tutorials\" \/>\n<meta property=\"og:description\" content=\"SQL Server Database Mail History Cleanup and prevent msdb database from growing\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/\" \/>\n<meta property=\"og:site_name\" content=\"Database Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2019-10-24T08:54:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-10-24T08:55:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/10\/Ads\u0131z-18.png\" \/>\n\t<meta property=\"og:image:width\" content=\"702\" \/>\n\t<meta property=\"og:image:height\" content=\"412\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Faruk Erdem\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Faruk Erdem\" \/>\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\":\"Article\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/\"},\"author\":{\"name\":\"Faruk Erdem\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/a7dfc5684c116e536b4e93ee214ccbfb\"},\"headline\":\"SQL Server Database Mail History Cleanup and Prevent msdb Database From Growing\",\"datePublished\":\"2019-10-24T08:54:02+00:00\",\"dateModified\":\"2019-10-24T08:55:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/\"},\"wordCount\":175,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/dbtut.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/10\/Ads\u0131z-18.png\",\"keywords\":[\"AFTER DELETE\",\"clean database mail history\",\"clean mail history\",\"Database Mail History Cleanup\",\"Delete All Database Mail Logs\",\"Delete All Database Mail Messages\",\"Delete All Mail Logs\",\"Delete All Mail Messages\",\"Delete Database Mail Logs Before a Certain Date\",\"Delete Database Mail Logs Before a Certain Date and With a Certain Event Type\",\"Delete Database Mail Logs With a Certains Event Type\",\"Delete Database Mail Messages Before a Certain Date\",\"Delete Database Mail Messages Before a Certain Date and With a Certain Status\",\"Delete Database Mail Messages With a Certains Status\",\"Delete Mail Logs Before a Certain Date\",\"Delete Mail Logs Before a Certain Date and With a Certain Event Type\",\"delete mail logs sql server\",\"Delete Mail Logs With a Certains Event Type\",\"Delete Mail Messages Before a Certain Date and With a Certain Status\",\"Delete Mail Messages With a Certains Status\",\"msdb growing too big due to database mail\",\"msdb is too big due to database mail log\",\"prevent msdb database from growing\",\"removing database mail history in sql server\",\"removing sql database mail history\",\"sysmail_delete_log_sp\",\"sysmail_delete_mailitems_sp\"],\"articleSection\":[\"MSSQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/\",\"url\":\"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/\",\"name\":\"SQL Server Database Mail History Cleanup and Prevent msdb Database From Growing - Database Tutorials\",\"isPartOf\":{\"@id\":\"https:\/\/dbtut.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/10\/Ads\u0131z-18.png\",\"datePublished\":\"2019-10-24T08:54:02+00:00\",\"dateModified\":\"2019-10-24T08:55:12+00:00\",\"description\":\"SQL Server Database Mail History Cleanup and prevent msdb database from growing\",\"breadcrumb\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/#primaryimage\",\"url\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/10\/Ads\u0131z-18.png\",\"contentUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/10\/Ads\u0131z-18.png\",\"width\":702,\"height\":412},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/dbtut.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Server Database Mail History Cleanup and Prevent msdb Database From Growing\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dbtut.com\/#website\",\"url\":\"https:\/\/dbtut.com\/\",\"name\":\"Database Tutorials\",\"description\":\"MSSQL, Oracle, PostgreSQL, MySQL, MariaDB, DB2, Sybase, Teradata, Big Data, NOSQL, MongoDB, Couchbase, Cassandra, Windows, Linux\",\"publisher\":{\"@id\":\"https:\/\/dbtut.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dbtut.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/dbtut.com\/#organization\",\"name\":\"dbtut\",\"url\":\"https:\/\/dbtut.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg\",\"contentUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg\",\"width\":223,\"height\":36,\"caption\":\"dbtut\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/a7dfc5684c116e536b4e93ee214ccbfb\",\"name\":\"Faruk Erdem\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ad1e61fb5a7c9a590e765f7cad8f2dc8332090f1ceb9a5ee2aa95c69213f0c50?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ad1e61fb5a7c9a590e765f7cad8f2dc8332090f1ceb9a5ee2aa95c69213f0c50?s=96&d=mm&r=g\",\"caption\":\"Faruk Erdem\"},\"url\":\"https:\/\/dbtut.com\/index.php\/author\/farukerdem\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SQL Server Database Mail History Cleanup and Prevent msdb Database From Growing - Database Tutorials","description":"SQL Server Database Mail History Cleanup and prevent msdb database from growing","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:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/","og_locale":"en_US","og_type":"article","og_title":"SQL Server Database Mail History Cleanup and Prevent msdb Database From Growing - Database Tutorials","og_description":"SQL Server Database Mail History Cleanup and prevent msdb database from growing","og_url":"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/","og_site_name":"Database Tutorials","article_published_time":"2019-10-24T08:54:02+00:00","article_modified_time":"2019-10-24T08:55:12+00:00","og_image":[{"width":702,"height":412,"url":"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/10\/Ads\u0131z-18.png","type":"image\/png"}],"author":"Faruk Erdem","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Faruk Erdem","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/#article","isPartOf":{"@id":"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/"},"author":{"name":"Faruk Erdem","@id":"https:\/\/dbtut.com\/#\/schema\/person\/a7dfc5684c116e536b4e93ee214ccbfb"},"headline":"SQL Server Database Mail History Cleanup and Prevent msdb Database From Growing","datePublished":"2019-10-24T08:54:02+00:00","dateModified":"2019-10-24T08:55:12+00:00","mainEntityOfPage":{"@id":"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/"},"wordCount":175,"commentCount":0,"publisher":{"@id":"https:\/\/dbtut.com\/#organization"},"image":{"@id":"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/#primaryimage"},"thumbnailUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/10\/Ads\u0131z-18.png","keywords":["AFTER DELETE","clean database mail history","clean mail history","Database Mail History Cleanup","Delete All Database Mail Logs","Delete All Database Mail Messages","Delete All Mail Logs","Delete All Mail Messages","Delete Database Mail Logs Before a Certain Date","Delete Database Mail Logs Before a Certain Date and With a Certain Event Type","Delete Database Mail Logs With a Certains Event Type","Delete Database Mail Messages Before a Certain Date","Delete Database Mail Messages Before a Certain Date and With a Certain Status","Delete Database Mail Messages With a Certains Status","Delete Mail Logs Before a Certain Date","Delete Mail Logs Before a Certain Date and With a Certain Event Type","delete mail logs sql server","Delete Mail Logs With a Certains Event Type","Delete Mail Messages Before a Certain Date and With a Certain Status","Delete Mail Messages With a Certains Status","msdb growing too big due to database mail","msdb is too big due to database mail log","prevent msdb database from growing","removing database mail history in sql server","removing sql database mail history","sysmail_delete_log_sp","sysmail_delete_mailitems_sp"],"articleSection":["MSSQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/","url":"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/","name":"SQL Server Database Mail History Cleanup and Prevent msdb Database From Growing - Database Tutorials","isPartOf":{"@id":"https:\/\/dbtut.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/#primaryimage"},"image":{"@id":"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/#primaryimage"},"thumbnailUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/10\/Ads\u0131z-18.png","datePublished":"2019-10-24T08:54:02+00:00","dateModified":"2019-10-24T08:55:12+00:00","description":"SQL Server Database Mail History Cleanup and prevent msdb database from growing","breadcrumb":{"@id":"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/#primaryimage","url":"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/10\/Ads\u0131z-18.png","contentUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/10\/Ads\u0131z-18.png","width":702,"height":412},{"@type":"BreadcrumbList","@id":"https:\/\/dbtut.com\/index.php\/2019\/10\/24\/sql-server-database-mail-history-cleanup-and-prevent-msdb-database-from-growing\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dbtut.com\/"},{"@type":"ListItem","position":2,"name":"SQL Server Database Mail History Cleanup and Prevent msdb Database From Growing"}]},{"@type":"WebSite","@id":"https:\/\/dbtut.com\/#website","url":"https:\/\/dbtut.com\/","name":"Database Tutorials","description":"MSSQL, Oracle, PostgreSQL, MySQL, MariaDB, DB2, Sybase, Teradata, Big Data, NOSQL, MongoDB, Couchbase, Cassandra, Windows, Linux","publisher":{"@id":"https:\/\/dbtut.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dbtut.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/dbtut.com\/#organization","name":"dbtut","url":"https:\/\/dbtut.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/#\/schema\/logo\/image\/","url":"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg","contentUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg","width":223,"height":36,"caption":"dbtut"},"image":{"@id":"https:\/\/dbtut.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/dbtut.com\/#\/schema\/person\/a7dfc5684c116e536b4e93ee214ccbfb","name":"Faruk Erdem","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ad1e61fb5a7c9a590e765f7cad8f2dc8332090f1ceb9a5ee2aa95c69213f0c50?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ad1e61fb5a7c9a590e765f7cad8f2dc8332090f1ceb9a5ee2aa95c69213f0c50?s=96&d=mm&r=g","caption":"Faruk Erdem"},"url":"https:\/\/dbtut.com\/index.php\/author\/farukerdem\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/13303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/users\/366"}],"replies":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/comments?post=13303"}],"version-history":[{"count":0,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/13303\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/media\/13304"}],"wp:attachment":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/media?parent=13303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/categories?post=13303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/tags?post=13303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}