{"id":9838,"date":"2020-09-11T08:39:49","date_gmt":"2020-09-10T22:39:49","guid":{"rendered":"https:\/\/database.guide\/?p=9838"},"modified":"2020-09-11T08:40:20","modified_gmt":"2020-09-10T22:40:20","slug":"update-a-database-mail-profile-in-sql-server-t-sql","status":"publish","type":"post","link":"https:\/\/database.guide\/update-a-database-mail-profile-in-sql-server-t-sql\/","title":{"rendered":"Update a Database Mail Profile in SQL Server (T-SQL)"},"content":{"rendered":"\n<p>In <a href=\"https:\/\/database.guide\/what-is-sql-server\/\" title=\"What is SQL Server?\">SQL Server<\/a>, you can use the <code>sysmail_update_profile_sp<\/code> stored procedure in the <code>msdb<\/code> database to update your existing Database Mail profiles with <a href=\"https:\/\/database.guide\/what-is-t-sql\/\" title=\"What is T-SQL?\">T-SQL<\/a>. <\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">Update the Profile Name &amp; Description<\/h2>\n\n\n\n<p>When both the profile ID and the profile name are specified, the procedure updates both the name and the description of the profile.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>EXECUTE msdb.dbo.sysmail_update_profile_sp  \n    @profile_id = 1,\n    @profile_name = 'Updated DB Admin Profile',\n    @description = 'Updated Profile for admin emails.';<\/code><\/pre>\n\n\n\n<p>In this example I update the name and description of the profile with an ID of 1. <\/p>\n\n\n\n<p>I could also do this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>EXECUTE msdb.dbo.sysmail_update_profile_sp  \n    @profile_id = 1,\n    @profile_name = 'Updated DB Admin Profile';<\/code><\/pre>\n\n\n\n<p>In which case, the profile name would be updated to the new name.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Update the Profile Description Only<\/h2>\n\n\n\n<p>You can update just the profile description by providing the profile name and the description.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>EXECUTE msdb.dbo.sysmail_update_profile_sp\n    @profile_name = 'Updated DB Admin Profile',\n    @description = 'Newly Updated Profile for admin emails.';<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">The Syntax<\/h2>\n\n\n\n<p>The official syntax goes like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sysmail_update_profile_sp &#91; &#91; @profile_id = ] profile_id , ] &#91; &#91; @profile_name = ] 'profile_name' , ]  \n    &#91; &#91; @description = ] 'description' ]<\/code><\/pre>\n\n\n\n<p>Note that the <code>sysmail_update_profile_sp<\/code> stored procedure is in the <code>msdb<\/code> database, and it&#8217;s owned by the <code>dbo<\/code> schema. Therefore, you&#8217;ll need to use three part naming if you execute it from outside the <code>msdb<\/code> database.<\/p>\n\n\n\n<p>You can also use the <code>sysmail_add_profile_sp<\/code> stored procedure to <a href=\"https:\/\/database.guide\/create-a-database-mail-profile-in-sql-server-t-sql\/\" title=\"Create a Database Mail Profile in SQL Server (T-SQL)\">create a new Database Mail profile<\/a>. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>In SQL Server, you can use the sysmail_update_profile_sp stored procedure in the msdb database to update your existing Database Mail profiles with T-SQL.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[10,77,104,61],"class_list":["post-9838","post","type-post","status-publish","format-standard","hentry","category-sql-server","tag-how-to","tag-mssql","tag-send-email","tag-t-sql"],"_links":{"self":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts\/9838","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/comments?post=9838"}],"version-history":[{"count":2,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts\/9838\/revisions"}],"predecessor-version":[{"id":9939,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts\/9838\/revisions\/9939"}],"wp:attachment":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/media?parent=9838"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/categories?post=9838"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/tags?post=9838"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}