sysmail_update_profileaccount_sp (Transact-SQL)
Updates the sequence number of an account within a Database Mail profile.
Returns an error if the account specified is not associated with the profile specified.
The sequence number determines the order in which Database Mail uses accounts in the profile. For a new e-mail message, Database Mail starts with the account that has the lowest sequence number. Should that account fail, Database Mail uses the account with the next highest sequence number, and so on until either Database Mail sends the message successfully, or the account with the highest sequence number fails. If the account with the highest sequence number fails, the e-mail message fails.
If more than one account exists with the same sequence number, Database Mail only uses one of those accounts for a given e-mail message. In this case, Database Mail makes no guarantees as to which of the accounts is used for that sequence number or that the same account is used from message to message.
The stored procedure sysmail_update_profileaccount_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.
The following example changes the sequence number of the account Admin-BackupServer within the profile AdventureWorks2008R2 Administrator in the msdb database. After executing this code, the sequence number for the account is 3, indicating it will be tried if the first two accounts fail.
EXECUTE msdb.dbo.sysmail_update_profileaccount_sp
@profile_name = 'AdventureWorks2008R2 Administrator'
,@account_name = 'Admin-BackupServer',
,@sequence_number = 3;