create procedure sys.sp_MSproxylogshippingmonitorsecondary
(
@mode tinyint -- 1 = add, 2 = delete, 3 = update
,@secondary_server sysname
,@secondary_database sysname = NULL
,@secondary_id uniqueidentifier
,@primary_server sysname = NULL
,@monitor_server sysname
,@primary_database sysname = NULL
,@restore_threshold int = NULL
,@threshold_alert int = NULL
,@threshold_alert_enabled bit = NULL
,@last_copied_file nvarchar(500) = NULL
,@last_copied_date datetime = NULL
,@last_copied_date_utc datetime = NULL
,@last_restored_file nvarchar(500) = NULL
,@last_restored_date datetime = NULL
,@last_restored_date_utc datetime = NULL
,@last_restored_latency int = NULL
,@history_retention_period int = NULL
)
with execute as 'dbo'
as
begin
set nocount on
declare @retcode int
,@linkcmd nvarchar(512)
-- should be executed in msdb
if (db_name() != N'msdb')
begin
raiserror (21482, 16, -1, N'sp_MSproxylogshippingmonitorsecondary', N'msdb')
return 1
end
-- process the monitor record in log_shipping_monitor_secondary on the monitor server
select @linkcmd = quotename(sys.fn_MSgetlogshippingmoniterlinkname(upper(@monitor_server))) + N'.msdb.sys.sp_processlogshippingmonitorsecondary'
begin try
exec @retcode = @linkcmd
@mode = @mode
,@secondary_server = @secondary_server
,@secondary_database = @secondary_database
,@secondary_id = @secondary_id
,@primary_server = @primary_server
,@monitor_server = @monitor_server
,@monitor_server_security_mode = 0
,@primary_database = @primary_database
,@restore_threshold = @restore_threshold
,@threshold_alert = @threshold_alert
,@threshold_alert_enabled = @threshold_alert_enabled
,@last_copied_file = @last_copied_file
,@last_copied_date = @last_copied_date
,@last_copied_date_utc = @last_copied_date_utc
,@last_restored_file = @last_restored_file
,@last_restored_date = @last_restored_date
,@last_restored_date_utc = @last_restored_date_utc
,@last_restored_latency = @last_restored_latency
,@history_retention_period = @history_retention_period
end try
begin catch
select @retcode = 1
end catch
if (@retcode != 0 or @@error != 0)
return 1
-- all done
return 0
end