Update a Database Mail Profile in SQL Server (T-SQL)

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.

Update the Profile Name & Description

When both the profile ID and the profile name are specified, the procedure updates both the name and the description of the profile.

EXECUTE msdb.dbo.sysmail_update_profile_sp  
    @profile_id = 1,
    @profile_name = 'Updated DB Admin Profile',
    @description = 'Updated Profile for admin emails.';

In this example I update the name and description of the profile with an ID of 1.

I could also do this:

EXECUTE msdb.dbo.sysmail_update_profile_sp  
    @profile_id = 1,
    @profile_name = 'Updated DB Admin Profile';

In which case, the profile name would be updated to the new name.

Update the Profile Description Only

You can update just the profile description by providing the profile name and the description.

EXECUTE msdb.dbo.sysmail_update_profile_sp
    @profile_name = 'Updated DB Admin Profile',
    @description = 'Newly Updated Profile for admin emails.';

The Syntax

The official syntax goes like this:

sysmail_update_profile_sp [ [ @profile_id = ] profile_id , ] [ [ @profile_name = ] 'profile_name' , ]  
    [ [ @description = ] 'description' ]

Note that the sysmail_update_profile_sp stored procedure is in the msdb database, and it’s owned by the dbo schema. Therefore, you’ll need to use three part naming if you execute it from outside the msdb database.

You can also use the sysmail_add_profile_sp stored procedure to create a new Database Mail profile.