Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSvalidate_agent_parameter

  No additional text.


Syntax
create procedure sys.sp_MSvalidate_agent_parameter (
    @profile_id      int,
    @parameter_name  sysname,
    @parameter_value nvarchar(255)
)
as
begin
    set nocount on
    declare  @agent_type int
                ,@original_parameter_name sysname
                ,@numeric_value int
                ,@selected_parameter_name sysname
                ,@min_value int
                ,@max_value int

    -- Initialize values
    select @agent_type = null
            ,@original_parameter_name = @parameter_name
            ,@numeric_value =null

    -- Make sure parameters are non-null
    if @profile_id is null
    begin
        raiserror(14043, 16, -1, N'@profile_id', 'sp_MSvalidate_agent_parameter')
        return(1)
    end

    if @parameter_name is null
    begin
        raiserror(14043, 16, -1, N'@parameter_name', 'sp_MSvalidate_agent_parameter')
        return(1)
    end

    if @parameter_value is null
    begin
        raiserror(14043, 16, -1, N'@parameter_value', 'sp_MSvalidate_agent_parameter')
        return(1)
    end

    -- make parameter name case-insensitive
    select @parameter_name = lower(@parameter_name collate SQL_Latin1_General_CP1_CI_AS)

    -- If the parameter name has a leading / or -, remove it
    if (left(@parameter_name, 1) in (N'/', N'-'))
    begin
        select @parameter_name = substring(@parameter_name, 2, len(@parameter_name) - 1)
    end

    -- Retrieve the information for this agent_type and parameter
    SELECT @selected_parameter_name = par.parameter_name
                ,@min_value = par.min_value
                ,@max_value = par.max_value
    FROM msdb..MSagentparameterlist AS par
        INNER JOIN msdb..MSagent_profiles as prof
        ON par.agent_type = prof.agent_type
    WHERE prof.profile_id=@profile_id
        -- make sure the parameter_name column is case-insensitive
        AND lower(parameter_name collate SQL_Latin1_General_CP1_CI_AS)=@parameter_name

    if @selected_parameter_name is null
    begin
        -- This profile_id %s does not exist, or it's agent type does not support parameter %s
        raiserror(21806, 16, -1,@profile_id, @original_parameter_name)
        return(1)
    end

    -- if possible convert the string param provided to the the numeric value
    if (isnumeric(@parameter_value)) = 1
    begin
        select @numeric_value = convert(int, @parameter_value)
    end
    else -- if parameter_value is non-numeric
    begin
        -- Certain parameters are not numeric
        -- Check for the parameter which have no default parameter value
        if (@parameter_name in (N'skiperrors',
                                        N'altsnapshotfolder',
                                        N'dynamicsnapshotlocation',
                                        N'inputmessagefile',
                                        N'outputmessagefile',
                                        N'interruptonmessagepattern',
                                        N'pauseonmessagepattern',
                                        N'publisherfailoverpartner',
                                        N'useoledbstreaming'))
        begin
            select @numeric_value = null
        end
        else -- something is wrong
        begin
            -- if we are here that means that we expected a numeric value but didn't find one
            -- Error: Value must be an integer
            raiserror(21805, 16, -1, @parameter_value, @original_parameter_name)
            return(1)
        end
    end

    -- Do parameter boundary checks using min_value and max_value (automatic for each param)
    if (@numeric_value is not null)
    begin
        if (@min_value is not null AND @numeric_value < @min_value)
        begin
            -- value is lower than allowed minimum
            raiserror(21405, 16, -1, @parameter_value, @original_parameter_name, @min_value)
            return(1)
        end
        if (@max_value is not null AND @numeric_value > @max_value and @parameter_name <> N'startqueuetimeout')
        begin
            -- value is higher than allowed maximum
            raiserror(21802, 16, -1, @parameter_value, @original_parameter_name, @max_value)
            return(1)
            end
    end

    -- Do additional checks for some parameters (that require more than boundary checks)
    -- These checks are parameter-specific
    if (@parameter_name = N'skiperrors')
    begin
        -- Empty string is valid.
        if @parameter_value <> N''
        begin
            -- Valid format: 11:22:33
            if  @parameter_value like N'%[0-9:]%' or
                @parameter_value like N':%' or
                @parameter_value like N'%:' or
                @parameter_value like N'%::%'
            begin
                raiserror(20601, 16, -1)
                return(1)
            end
            -- cannot have more than 10 errors
            if  @parameter_value like N'%:%:%:%:%:%:%:%:%:%:%'
            begin
                raiserror(20602, 16, -1)
                return(1)
            end
        end
    end
    else if (@parameter_name = N'startqueuetimeout')
    begin
        if @numeric_value <> 0 and @numeric_value < @max_value
        begin
            raiserror(21404, 16, -1, @parameter_value, @original_parameter_name)
            return(1)
        end
    end
    else if (@parameter_name = N'useoledbstreaming')
    begin
        -- Empty string is valid.
        if @parameter_value != N''
        begin
            raiserror(21402, 16, -1, @original_parameter_name)
            return(1)
        end
    end
    return(0)
end

 
Last revision 2008RTM
See also

  sp_add_agent_parameter (Procedure)
sp_change_agent_parameter (Procedure)
sp_MSdrop_replcom (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