sysmail_help_profileaccount_sp (Transact-SQL)

适用于:SQL Server

列出与一个或多个数据库邮件配置文件相关联的帐户。

Transact-SQL 语法约定

语法

sysmail_help_profileaccount_sp
   { [ @profile_id = ] profile_id
      | [ @profile_name = ] 'profile_name' }
   [ , { [ @account_id = ] account_id
         | [ @account_name = ] 'account_name' } ]
[ ; ]

参数

[ @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均为 NULL 时,列出配置文件中的所有帐户。

[ @account_name = ] 'account_name'

要列出的帐户的名称。 @account_name为 sysname,默认值为 NULL. 当@account_id@account_name均为 NULL 时,列出配置文件中的所有帐户。

返回代码值

0(成功)或 1(失败)。

结果集

返回包含以下列的结果集。

列名称 数据类型 说明
profile_id int 配置文件的配置文件 ID。
profile_name sysname 配置文件的名称。
account_id int 帐户的帐户 ID。
account_name sysname 帐户的名称。
sequence_number int 配置文件中的帐户的序号。

注解

如果未 指定@profile_id@profile_name ,此存储过程将返回实例中每个配置文件的信息。

存储过程 sysmail_help_profileaccount_sp 位于 msdb 数据库中,由 dbo 架构拥有。 如果当前数据库不是 msdb,则必须使用三部分名称执行该过程。

权限

此存储过程由 db_owner 角色拥有。 你可以为任何用户授予 EXECUTE 权限,但这些权限可能会在 SQL Server 升级期间被重写。

示例

A. 按名称列出特定配置文件的帐户

以下示例通过指定配置文件名称以列出 AdventureWorks Administrator 配置文件的信息。

EXEC msdb.dbo.sysmail_help_profileaccount_sp
   @profile_name = 'AdventureWorks Administrator';

下面是示例结果集,由于行的长度原因而进行了编辑:

profile_id  profile_name                 account_id  account_name         sequence_number
----------- ---------------------------- ----------- -------------------- ---------------
131         AdventureWorks Administrator 197         Admin-MainServer     1
131         AdventureWorks Administrator 198         Admin-BackupServer   2

B. 按配置文件 ID 列出特定配置文件的帐户

以下示例通过指定配置文件的配置文件 ID 以列出 AdventureWorks Administrator 配置文件的信息。

EXEC msdb.dbo.sysmail_help_profileaccount_sp
    @profile_id = 131 ;

下面是示例结果集,由于行的长度原因而进行了编辑:

profile_id  profile_name                 account_id  account_name         sequence_number
----------- ---------------------------- ----------- -------------------- ---------------
131         AdventureWorks Administrator 197         Admin-MainServer     1
131         AdventureWorks Administrator 198         Admin-BackupServer   2

°C 列出所有配置文件的帐户

以下示例列出实例中的所有配置文件的帐户。

EXEC msdb.dbo.sysmail_help_profileaccount_sp;

下面是示例结果集,由于行的长度原因而进行了编辑:

profile_id  profile_name                 account_id  account_name         sequence_number
----------- ---------------------------- ----------- -------------------- ---------------
131         AdventureWorks Administrator 197         Admin-MainServer     1
131         AdventureWorks Administrator 198         Admin-BackupServer   2
106         AdventureWorks Operator      210         Operator-MainServer  1