--- title: "sysmail_add_profile_sp (Transact-SQL) | Microsoft Docs" ms.custom: "" ms.date: "03/06/2017" ms.prod: "sql-non-specified" ms.reviewer: "" ms.suite: "" ms.technology: - "database-engine" ms.tgt_pltfrm: "" ms.topic: "language-reference" f1_keywords: - "sysmail_add_profile_sp_TSQL" - "sysmail_add_profile_sp" dev_langs: - "TSQL" helpviewer_keywords: - "sysmail_add_profile_sp" ms.assetid: a828e55c-633a-41cf-9769-a0698b446e6c caps.latest.revision: 37 author: "JennieHubbard" ms.author: "jhubbard" manager: "jhubbard" --- # sysmail_add_profile_sp (Transact-SQL) [!INCLUDE[tsql-appliesto-ss2008-xxxx-xxxx-xxx_md](../../includes/tsql-appliesto-ss2008-xxxx-xxxx-xxx-md.md)] Creates a new Database Mail profile. ![Topic link icon](../../database-engine/configure-windows/media/topic-link.gif "Topic link icon") [Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md) ## Syntax ``` sysmail_add_profile_sp [ @profile_name = ] 'profile_name' [ , [ @description = ] 'description' ] [ , [ @profile_id = ] new_profile_id OUTPUT ] ``` ## Arguments [ **@profile_name** = ] **'***profile_name***'** The name for the new profile. *profile_name* is **sysname**, with no default. [ **@description** = ] **'***description***'** The optional description for the new profile. *description* is **nvarchar(256)**, with no default. [ **@profile_id** = ] *new_profile_id***OUTPUT** Returns the ID for the new profile. *new_profile_id* is **int**, with a default of NULL. ## Return Code Values **0** (success) or **1** (failure) ## Remarks A Database Mail profile holds any number of Database Mail accounts. Database Mail stored procedures can refer to a profile by either the profile name or the profile id generated by this procedure. For more information about adding an account to a profile, see [sysmail_add_profileaccount_sp (Transact-SQL)](../../relational-databases/system-stored-procedures/sysmail-add-profileaccount-sp-transact-sql.md). The profile name and description can be changed with the stored procedure **sysmail_update_profile_sp**, while the profile id remains constant for the life of the profile. The profile name must be unique for the Microsoft [!INCLUDE[ssDEnoversion](../../includes/ssdenoversion-md.md)] or the stored procedure returns an error. The stored procedure **sysmail_add_profile_sp** is in the **msdb** database and is owned by the **dbo** schema. The procedure must be executed with a three-part name if the current database is not **msdb**. ## Permissions Execute permissions for this procedure default to members of the **sysadmin** fixed server role. ## Examples **A. Creating a new profile** The following example creates a new Database Mail profile named `AdventureWorks Administrator`. ``` EXECUTE msdb.dbo.sysmail_add_profile_sp @profile_name = 'AdventureWorks Administrator', @description = 'Profile used for administrative mail.' ; ``` **B. Creating a new profile, saving the profile id in a variable** The following example creates a new Database Mail profile named `AdventureWorks Administrator`. The example stores the profile id number in the variable `@profileId` and returns a result set containing the profile id number for the new profile. ``` DECLARE @profileId INT ; EXECUTE msdb.dbo.sysmail_add_profile_sp @profile_name = 'AdventureWorks Administrator', @description = 'Profile used for administrative mail.', @profile_id = @profileId OUTPUT ; SELECT @profileId ; ``` ## See Also [Database Mail](../../relational-databases/database-mail/database-mail.md) [Create a Database Mail Account](../../relational-databases/database-mail/create-a-database-mail-account.md) [Database Mail Configuration Objects](../../relational-databases/database-mail/database-mail-configuration-objects.md) [Database Mail Stored Procedures (Transact-SQL)](../../relational-databases/system-stored-procedures/database-mail-stored-procedures-transact-sql.md)