Transact-SQL 参考

sp_add_log_shipping_primary

将新的主服务器添加到 log_shipping_primaries 表。

语法

sp_add_log_shipping_primary
    { [ @primary_server_name = ] 'primary_server_name' ,
    { [ @primary_database_name = ] 'primary_database_name' }
    [ , [ @maintenance_plan_id = ] maintenance_plan_id ]
    [ , [ @backup_threshold = ] backup_threshold ]
    [ , [ @threshold_alert = ] threshold_alert ]
    [ , [ @threshold_alert_enabled = ] threshold_alert_enabled ]
    [ , [ @planned_outage_start_time = ] planned_outage_start_time ]
    [ , [ @planned_outage_end_time = ] planned_outage_end_time ]
    [ , [ @planned_outage_weekday_mask = ] planned_outage_weekday_mask ]
    [ , [ @primary_id = ] primary_id OUTPUT ]

参数

[@primary_server_name =] 'primary_server_name'

主服务器名称。primary_server_name 的数据类型为 sysname,没有默认值。

[@primary_database_name =] 'primary_database_name'

主服务器上的数据库名称。primary_database_name 的数据类型为 sysname,没有默认值。

[@maintenance_plan_id =] maintenance_plan_id

备份事务日志的维护计划的 ID。maintenance_plan_id 的数据类型为 uniqueidentifier,默认设置为 NULL。

[@backup_threshold =] backup_threshold

在最后一次备份后 threshold_alert 错误产生之前的时间长度,以分钟为单位。backup_threshold 的数据类型为 int,默认设置为 60 分钟。

[@threshold_alert =] threshold_alert

超出备份阈值时引发的错误。threshold_alert 的数据类型为 int,默认设置为 NULL。

[@threshold_alert_enabled =] threshold_alert_enabled

指定当超出 backup_threshold 值时是否发出警报。默认设置为一 (1),意味着将发出警报。threshold_alert_enabled 的数据类型为 bit

[@planned_outage_start_time =] planned_outage_start_time

计划的停歇启动的时间,格式为 HHMMSS。在计划的停歇期间,如果超出备份阈值将不会发出警报。planned_outage_start_time 的数据类型为 int,默认设置为零 (0)。

[@planned_outage_end_time =] planned_outage_end_time

计划的停歇结束的时间,格式为 HHMMSS。planned_outage_end_time 的数据类型为 int,默认设置为零 (0)。

[@planned_outage_weekday_mask =] planned_outage_weekday_mask

指定计划的停歇发生在星期几。planned_outage_weekday_mask 的数据类型为 int,默认设置为零 (0)。它可以是下列值中的一个或多个。

1 星期日
2 星期一
4 星期二
8 星期三
16 星期四
32 星期五
64 星期六

[@primary_id =] primary_id OUTPUT

新主服务器和数据库对的唯一 ID。primary_id 的数据类型为 uniqueidentifier

返回代码值

0(成功)或 1(失败)

注释

若要指定监视主服务器,请在监视服务器上执行 sp_add_log_shipping_primary

权限

只有 sysadmin 固定服务器角色的成员才可以执行sp_add_log_shipping_primary