sysmail_update_profileaccount_sp (Transact-SQL)

更新数据库邮件配置文件中帐户的序列号。

主题链接图标Transact-SQL 语法约定

语法

sysmail_update_profileaccount_sp  { [ @profile_id = ] profile_id 
| [ @profile_name = ] 'profile_name' } ,
    { [ @account_id = ] account_id | [ @account_name = ] 'account_name' } ,
    [ @sequence_number = ] sequence_number

参数

  • [ @profile_id = ] profile_id
    要更新的配置文件的配置文件 ID。profile_id 的数据类型为 int,默认值为 NULL。必须指定 profile_id 或 profile_name。

  • [ @profile_name = ] 'profile_name'
    要更新的配置文件的配置文件名。profile_name 的数据类型为 sysname,默认值为 NULL。必须指定 profile_id 或 profile_name。

  • [ @account_id = ] account_id
    要更新的帐户的 ID。account_id 的数据类型为 int,默认值为 NULL。必须指定 account_id 或 account_name。

  • [ @account_name = ] 'account_name'
    要更新的帐户的名称。account_name 的数据类型为 sysname,默认值为 NULL。必须指定 account_id 或 account_name。

  • [ @sequence_number = ] sequence_number
    帐户的新序列号。sequence_number 的数据类型为 int,无默认值。序列号可以确定帐户在配置文件中的使用顺序。

返回代码值

0(成功)或 1(失败)

结果集

注释

如果指定的帐户与指定的配置文件不关联,则返回错误。

序列号可以确定数据库邮件使用配置文件中帐户的顺序。对于新的电子邮件,数据库邮件将从序列号最小的帐户开始。如果该帐户失败,数据库邮件就使用具有下一个序列号较大的帐户,依此类推,直到数据库邮件成功发送邮件,或者序列号最大的帐户也失败为止。如果具有最高序列号的帐户失败,则电子邮件发送失败。

如果存在具有相同序列号的多个帐户,则数据库邮件将仅使用其中一个帐户发送给定的电子邮件。在此情况下,数据库邮件不能保证使用具有该序列号的特定帐户,也不能保证使用同一个帐户发送各个邮件。

存储过程 sysmail_update_profileaccount_spmsdb 数据库中,由 dbo 架构所有。如果当前数据库不是 msdb,则必须使用由三部分构成的名称来执行该过程。

权限

此过程的执行权限默认授予 sysadmin 固定服务器角色的成员。

示例

以下示例将更改 msdb 数据库中配置文件 AdventureWorks2008R2 Administrator 内的帐户 Admin-BackupServer 的序列号。执行此代码后,该帐户的序列号为 3,指示前两个帐户失败后将尝试使用此帐户。

EXECUTE msdb.dbo.sysmail_update_profileaccount_sp
    @profile_name = 'AdventureWorks2008R2 Administrator'
    ,@account_name = 'Admin-BackupServer',
    ,@sequence_number = 3;