Database Mail XPs 服务器配置选项Database Mail XPs Server Configuration Option
适用于:Applies to: SQL ServerSQL Server(所有支持的版本)
SQL ServerSQL Server (all supported versions)
SQL ServerSQL Server(所有支持的版本)
SQL ServerSQL Server (all supported versions)
使用 DatabaseMail XPs 选项可以在此服务器上启用数据库邮件。Use the DatabaseMail XPs option to enable Database Mail on this server. 可能的值包括:The possible values are:
0
:数据库邮件不可用(默认)。0
: Database Mail isn't available (default).1
:数据库邮件可用。1
: Database Mail is available.
该设置立即生效,无需停止并重新启动服务器。The setting takes effect immediately without a server stop and restart.
启用数据库邮件后,必须配置一个数据库邮件主机数据库,才能使用 Database Mail。After enabling Database Mail, you must configure a Database Mail host database to use Database Mail.
使用“数据库邮件配置向导”配置数据库邮件可以启用 msdb
数据库中的数据库邮件扩展存储过程。Configuring Database Mail using the Database Mail Configuration Wizard enables the Database Mail extended stored procedures in the msdb
database. 如果使用的是“数据库邮件配置向导”,则无需使用下面的 sp_configure
示例。If you use the Database Mail Configuration Wizard, you do not have to use the sp_configure
example below.
将“Database Mail XPs”选项设置为 0
可以防止启动数据库邮件。Setting the Database Mail XPs option to 0
prevents Database Mail from starting. 如果该选项设置为 0
时数据库邮件正在运行,则它将继续运行并发送邮件,直到数据库邮件空闲时间达到 DatabaseMailExeMinimumLifeTime
选项中配置的时间。If it is running when the option is set to 0
, it continues to run and send mail until it is idle for the time configured in the DatabaseMailExeMinimumLifeTime
option.
示例Examples
以下示例启用了 Database Mail 扩展存储过程。The following example enables the Database Mail extended stored procedures.
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Database Mail XPs', 1;
GO
RECONFIGURE
GO
如果数据库邮件扩展存储过程尚未启用,请使用以下示例。The following example enables the Database Mail extended stored procedures if it is not already enabled.
IF EXISTS (
SELECT 1 FROM sys.configurations
WHERE NAME = 'Database Mail XPs' AND VALUE = 0)
BEGIN
PRINT 'Enabling Database Mail XPs'
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE
EXEC sp_configure 'Database Mail XPs', 1;
RECONFIGURE
END