May 7, 2012

sp_MSadd_subscriber_schedule (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_MSadd_subscriber_schedule(nvarchar @publisher
, nvarchar @subscriber
, smallint @agent_type
, int @frequency_type
, int @frequency_interval
, int @frequency_relative_interval
, int @frequency_recurrence_factor
, int @frequency_subday
, int @frequency_subday_interval
, int @active_start_time_of_day
, int @active_end_time_of_day
, int @active_start_date
, int @active_end_date)

MetaData:

 CREATE PROCEDURE sys.sp_MSadd_subscriber_schedule  
(
@publisher sysname,
@subscriber sysname,
@agent_type smallint = 0, -- 0 for distribution agent, 1 for merge agent
@frequency_type int = 4,
@frequency_interval int = 1,
@frequency_relative_interval int = 1,
@frequency_recurrence_factor int = 0,
@frequency_subday int = 4,
@frequency_subday_interval int = 5,
@active_start_time_of_day int = 0,
@active_end_time_of_day int = 235959,
@active_start_date int = 0,
@active_end_date int = 99991231
)
AS
begin
set nocount on
declare @retcode int

--
-- security check
-- only sysadmin can execute this
--
if (isnull(is_srvrolemember('sysadmin'),0) = 0)
begin
raiserror(21089, 16, -1)
return (1)
end
--
-- security check
-- Has to be executed from distribution database
--
if (sys.fn_MSrepl_isdistdb (db_name()) != 1)
begin
raiserror(21482, 16, -1, 'sp_MSadd_subscriber_schedule', 'distribution')
return (1)
end

-- Add the subscriber to dbo.sysservers as a RPC server, if it does not
-- already exist.
--
if not exists (select * from master.dbo.sysservers where UPPER(srvname) = UPPER(@subscriber))
begin
DECLARE @upper_subscriber sysname

SELECT @upper_subscriber = UPPER(@subscriber collate database_default)

exec @retcode = dbo.sp_addserver @upper_subscriber
if @retcode <> 0
return 1
end

-- only insert if it doesn't exist --
if not exists (select *
from MSsubscriber_schedule
where UPPER(publisher) = UPPER(@publisher)
and UPPER(subscriber) = UPPER(@subscriber)
and agent_type = @agent_type)
begin
insert MSsubscriber_schedule (publisher, subscriber, agent_type,
frequency_type, frequency_interval, frequency_relative_interval,
frequency_recurrence_factor, frequency_subday, frequency_subday_interval,
active_start_time_of_day, active_end_time_of_day, active_start_date,
active_end_date)

values (@publisher, @subscriber, @agent_type,
@frequency_type, @frequency_interval, @frequency_relative_interval,
@frequency_recurrence_factor, @frequency_subday, @frequency_subday_interval,
@active_start_time_of_day, @active_end_time_of_day, @active_start_date,
@active_end_date)
if @@error <> 0
return 1
end
end

No comments:

Post a Comment

Total Pageviews