Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSprocesslogshippingretentioncleanup

  No additional text.


Syntax
create procedure sys.sp_MSprocesslogshippingretentioncleanup
(
    @agent_id uniqueidentifier
    ,@agent_type tinyint  -- 0 = backup, 1 = copy, 2 = restore
    ,@monitor_server sysname
    ,@monitor_server_security_mode bit = 1
    ,@history_retention_period int
    ,@curdate_utc datetime
)
as
begin
    set nocount on
    declare @retcode int
                ,@cutoff_time_utc datetime
                ,@linkcmd nvarchar(512)
    
    -- compute the cutofftime
    
    select @cutoff_time_utc = dateadd(minute, -@history_retention_period, @curdate_utc)
    
    -- cleanup history_detail
    
    delete from msdb.dbo.log_shipping_monitor_history_detail
    where agent_id = @agent_id
        and agent_type = @agent_type
        and log_time_utc < @cutoff_time_utc
    
    -- cleanup error_detail
    
    delete from msdb.dbo.log_shipping_monitor_error_detail
    where agent_id = @agent_id
        and agent_type = @agent_type
        and log_time_utc < @cutoff_time_utc
    
    -- Do we need have remote monitor
    
    if (upper(@monitor_server) != upper(@@servername))
    begin
        if (@monitor_server_security_mode = 0) and (suser_name() != SUSER_SNAME(0x01))
        begin
            
            -- Process remote monitor using proxy
            
            exec @retcode = msdb.sys.sp_MSproxylogshippingretentioncleanup
                    @agent_id = @agent_id
                    ,@agent_type = @agent_type
                    ,@monitor_server = @monitor_server
                    ,@history_retention_period = @history_retention_period
                    ,@curdate_utc = @curdate_utc
        end
        else
        begin
            
            -- integrated -do not use proxy
            
            select @linkcmd = quotename(sys.fn_MSgetlogshippingmoniterlinkname(upper(@monitor_server))) + N'.msdb.sys.sp_processlogshippingretentioncleanup'
            begin try
                exec @retcode = @linkcmd
                    @agent_id = @agent_id
                    ,@agent_type = @agent_type
                    ,@monitor_server = @monitor_server
                    ,@monitor_server_security_mode = 1
                    ,@history_retention_period = @history_retention_period
                    ,@curdate_utc = @curdate_utc
            end try
            begin catch
                select @retcode = 1
            end catch
        end
        if (@retcode != 0 or @@error != 0)
            return 1
    end
    
    -- all done
    
    return 0
end

 
Last revision 2008RTM
See also

  sp_cleanup_log_shipping_history (Procedure)
sp_processlogshippingretentioncleanup (Procedure)
       



News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash