sysmail_add_profile_sp (Transact-SQL)sysmail_add_profile_sp (Transact-SQL)

本主題適用於:是SQL Server (從 2008 開始)否Azure SQL Database否Azure SQL 資料倉儲 否平行處理資料倉儲 THIS TOPIC APPLIES TO:yesSQL Server (starting with 2008)noAzure SQL DatabasenoAzure SQL Data Warehouse noParallel Data Warehouse

建立新的 Database Mail 設定檔。Creates a new Database Mail profile.

主題連結圖示 Transact-SQL 語法慣例Topic link icon Transact-SQL Syntax Conventions

語法Syntax


sysmail_add_profile_sp [ @profile_name = ] 'profile_name'  
    [ , [ @description = ] 'description' ]  
    [ , [ @profile_id = ] new_profile_id OUTPUT ]  

引數Arguments

[ @profile_name = ] 'profile_name'[ @profile_name = ] 'profile_name'
新設定檔的名稱。The name for the new profile. profile_namesysname,沒有預設值。profile_name is sysname, with no default.

[ @description = ] 'description'[ @description = ] 'description'
新設定檔的選擇性描述。The optional description for the new profile. 描述nvarchar (256),沒有預設值。description is nvarchar(256), with no default.

[ @profile_id = ] new_profile_idOUTPUT[ @profile_id = ] new_profile_idOUTPUT
傳回新設定檔的識別碼。Returns the ID for the new profile. new_profile_idint,預設值是 NULL。new_profile_id is int, with a default of NULL.

傳回碼值Return Code Values

0 (成功) 或1 (失敗)0 (success) or 1 (failure)

備註Remarks

Database Mail 設定檔會保存任意數目的 Database Mail 帳戶。A Database Mail profile holds any number of Database Mail accounts. Database Mail 預存程序可以利用這個程序所產生的設定檔名稱或設定檔識別碼來參考設定檔。Database Mail stored procedures can refer to a profile by either the profile name or the profile id generated by this procedure. 如需將帳戶新增至設定檔的詳細資訊,請參閱sysmail_add_profileaccount_sp (TRANSACT-SQL)For more information about adding an account to a profile, see sysmail_add_profileaccount_sp (Transact-SQL).

預存程序,則可以變更的設定檔名稱和描述sysmail_update_profile_sp,而這個設定檔識別碼維持不變的存留期間的設定檔。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.

Microsoft SQL Server Database EngineSQL Server Database Engine 的設定檔名稱必須是唯一的,否則,預存程序會傳回一則錯誤。The profile name must be unique for the Microsoft SQL Server Database EngineSQL Server Database Engine or the stored procedure returns an error.

預存程序sysmail_add_profile_sp處於msdb資料庫,擁有者是dbo結構描述。The stored procedure sysmail_add_profile_sp is in the msdb database and is owned by the dbo schema. 此程序必須利用三部分名稱來執行,如果目前的資料庫不是msdbThe procedure must be executed with a three-part name if the current database is not msdb.

PermissionsPermissions

執行此程序預設值,成員的權限sysadmin固定的伺服器角色。Execute permissions for this procedure default to members of the sysadmin fixed server role.

範例Examples

A.建立新的設定檔A. Creating a new profile

下列範例會建立名稱為 AdventureWorks Administrator 的新 Database Mail 設定檔。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.建立新的設定檔,將設定檔識別碼儲存在變數B. Creating a new profile, saving the profile id in a variable

下列範例會建立名稱為 AdventureWorks Administrator 的新 Database Mail 設定檔。The following example creates a new Database Mail profile named AdventureWorks Administrator. 這個範例會將設定檔識別碼儲存在 @profileId 變數中,且會傳回包含新設定檔之設定檔識別碼的結果集。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 Database Mail
建立 Database Mail 帳戶 Create a Database Mail Account
Database Mail 組態物件 Database Mail Configuration Objects
Database Mail 預存程序(Transact SQL)Database Mail Stored Procedures (Transact-SQL)