sysmail_help_profileaccount_sp (Transact-SQL)

適用於:SQL Server

列出與一個或多個 Database Mail 設定檔相關聯的帳戶。

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

要列出之配置檔的配置檔標識碼。 @profile_id為 int,預設值為 NULL必須指定@profile_id@profile_name

[ @profile_name = ] 'profile_name'

要列出之配置檔的配置檔名稱。 @profile_name為 sysname,預設值為 NULL必須指定@profile_id@profile_name

[ @account_id = ] account_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 配置檔的設定檔識別碼。
profile_name sysname 設定檔的名稱。
account_id int 帳戶的帳戶標識碼。
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. 依配置檔識別碼列出特定配置檔的帳戶

下列範例顯示藉由指定配置檔的設定檔識別碼來列出設定檔的資訊 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