May 7, 2012

sp_MScache_agent_parameter (Transact-SQL MetaData) Definition

Please note: that the following source code is provided and copyrighted by Microsoft and is for educational purpose only.
The meta data is from an SQL 2012 Server.

I have posted alot more, find the whole list here.

Goto Definition or MetaData

Definition:

sys.sp_MScache_agent_parameter(nvarchar @profile_name
, nvarchar @parameter_name
, nvarchar @parameter_value)

MetaData:

 --  This proc caches agent profile paramaters on the subscriber database  
create procedure sys.sp_MScache_agent_parameter(
@profile_name sysname,
@parameter_name sysname,
@parameter_value nvarchar(255)
)AS
declare @slash_parameter_name sysname
declare @dash_parameter_name sysname
declare @retcode int

--
-- security check
--
exec @retcode = sys.sp_MSreplcheck_subscribe
if @@ERROR <> 0 or @retcode <> 0
begin
return(1)
end

select @parameter_name = LTRIM(RTRIM(@parameter_name))
select @parameter_value = LTRIM(RTRIM(@parameter_value))

-- Append leading '-' when not given
if (substring(@parameter_name, 1, 1) <> '/' and
substring(@parameter_name, 1, 1) <> '-')
BEGIN
select @parameter_name = N'-' + @parameter_name
END

select @slash_parameter_name = lower(stuff(@parameter_name, 1, 1, N'/') collate SQL_Latin1_General_CP1_CS_AS)
select @dash_parameter_name = lower(stuff(@parameter_name, 1, 1, N'-') collate SQL_Latin1_General_CP1_CS_AS)

IF exists ( select * from dbo.MSmerge_agent_parameters
where profile_name = @profile_name and
(lower(parameter_name collate SQL_Latin1_General_CP1_CS_AS) = @slash_parameter_name collate SQL_Latin1_General_CP1_CS_AS or
lower(parameter_name collate SQL_Latin1_General_CP1_CS_AS) = @dash_parameter_name collate SQL_Latin1_General_CP1_CS_AS))
BEGIN
update dbo.MSmerge_agent_parameters set value = @parameter_value where
profile_name = @profile_name and
(lower(parameter_name collate SQL_Latin1_General_CP1_CS_AS) = @slash_parameter_name collate SQL_Latin1_General_CP1_CS_AS or
lower(parameter_name collate SQL_Latin1_General_CP1_CS_AS) = @dash_parameter_name collate SQL_Latin1_General_CP1_CS_AS)

if @@error <> 0
return(1)
END
ELSE
BEGIN
insert into dbo.MSmerge_agent_parameters values (@profile_name, @parameter_name, @parameter_value) ;
if @@error <> 0
return(1)
END

No comments:

Post a Comment

Total Pageviews