Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_replmonitorchangepublicationthreshold

  No additional text.


Syntax
create procedure sys.sp_replmonitorchangepublicationthreshold
(
    @publisher sysname -- cannot be null
    ,@publisher_db sysname -- cannot be null
    ,@publication sysname -- cannot be null
    ,@publication_type int = NULL -- NULL for wildcard, 0 transactional 1 snapshot 2 merge
    ,@metric_id int = NULL -- NULL if name is specified
    ,@thresholdmetricname sysname = NULL -- NULL if id is specified
    ,@value int = NULL -- NULL - skip updating value
    ,@shouldalert bit = NULL -- NULL - skip updating value
    ,@mode tinyint = 1 -- mode of operation 1 = enable, 2 = disable
)
as
begin
    set nocount on
    declare @retcode int
                ,@publication_id int
    
    -- constants
    
    declare @modeenable tinyint
                ,@modedisable tinyint

    
    -- initialize
    
    select @modeenable = 1
                ,@modedisable = 2
    
    -- security check : replmonitor
    
    if not (is_member(N'db_owner') = 1 or isnull(is_member(N'replmonitor'),0) = 1)
    begin
        raiserror(14260, 16, -1)
        return (1)
    end
    
    -- security: Has to be executed from distribution database
    
    if sys.fn_MSrepl_isdistdb (db_name()) != 1
    begin
    	raiserror (21482, 16, -1, 'sp_replmonitorchangepublicationthreshold', 'distribution')
    	return 1
    end
    
    -- check @mode
    
    if (@mode not in (@modeenable, @modedisable))
    begin
        raiserror(21402, 16, -1, '@mode')
    	return 1
    end
    
    -- validate publication
    
    select @publication_id = p.publication_id
    from dbo.MSpublications as p join sys.servers as s
        on p.publisher_id = s.server_id
        and upper(s.name) = upper(@publisher)
        and p.publisher_db = @publisher_db
        and p.publication = @publication
        and p.publication_type= case when (@publication_type is null) then p.publication_type else @publication_type end
    if (@publication_id is null)
    begin
        raiserror(20026, 16, 1, @publication)
        return 1
    end
    
    -- validate metric
    
    if (@metric_id is null and @thresholdmetricname is null)
    begin
        raiserror(21821, 16, -1, '@metric_id', '@thresholdmetricname')
        return 1
    end
    else if (@metric_id is not null and @thresholdmetricname is null)
    begin
        select @thresholdmetricname = title
        from msdb.dbo.MSreplmonthresholdmetrics
        where metric_id = @metric_id
        if (@thresholdmetricname is null)
        begin
            raiserror(14200, 16, 1, '@metric_id')
            return 1
        end
    end
    else if (@metric_id is null and @thresholdmetricname is not null)
    begin
        select @metric_id = metric_id
        from msdb.dbo.MSreplmonthresholdmetrics
        where title = lower(@thresholdmetricname)
        if (@metric_id is null)
        begin
            raiserror(14200, 16, 2, '@thresholdmetricname')
            return 1
        end
    end
    else
    begin
        raiserror(21821, 16, -1, '@metric_id', '@thresholdmetricname')
        return 1
    end
    
    -- proceed only if row exists
    
    if exists (select * from dbo.MSpublicationthresholds
        where publication_id = @publication_id
            and metric_id = @metric_id)
    begin
        
        -- Process according to the mode and update
        
        if (@mode = @modeenable)
        begin
            -- enable state
            update dbo.MSpublicationthresholds
            set value = case when (@value is null) then value else @value end
                ,shouldalert = case when (@shouldalert is null) then shouldalert else @shouldalert end
                ,isenabled=1
            where publication_id = @publication_id
                and metric_id = @metric_id
        end
        else
        begin
            -- disable state
            update dbo.MSpublicationthresholds
            set isenabled=0
            where publication_id = @publication_id
                and metric_id = @metric_id
        end
        
        -- Check if enable/disable update failed
        
        if (@@error != 0)
            return 1
    end
    else
    begin
        raiserror(21823, 16, -1, 'enable/disable', 'MSpublicationthresholds')
        return 1
    end
    
    -- return
    
    return 0
end

 
Last revision 2008RTM
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