June 4, 2012

sp_MSupdateinitiallightweightsubscription (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_MSupdateinitiallightweightsubscription(nvarchar @publisher
, nvarchar @publisher_db
, nvarchar @publication_name
, uniqueidentifier @pubid
, bit @allow_subscription_copy
, int @retention
, int @conflict_logging
, int @status
, bit @allow_synctoalternate
, int @replicate_ddl
, bit @automatic_reinitialization_policy)

MetaData:

 create procedure sys.sp_MSupdateinitiallightweightsubscription  
@publisher sysname,
@publisher_db sysname,
@publication_name sysname,
@pubid uniqueidentifier,
@allow_subscription_copy bit,
@retention int,
@conflict_logging int,
@status int,
@allow_synctoalternate bit,
@replicate_ddl int,
@automatic_reinitialization_policy bit
as
set nocount on

declare @retcode int

-- security check
exec @retcode = sys.sp_MSreplcheck_subscribe
if @retcode <> 0 or @@error <> 0 return 1

declare @pubid_local uniqueidentifier

select @pubid_local = pubid from dbo.sysmergepublications
where upper(publisher collate SQL_Latin1_General_CP1_CS_AS) = upper(@publisher collate SQL_Latin1_General_CP1_CS_AS) and
publisher_db = @publisher_db and
name = @publication_name

update dbo.sysmergepublications
set pubid= @pubid,
retention= @retention,
status= @status,
centralized_conflicts= case @conflict_logging
when 1 then 1
when 2 then 1
else 0
end,
decentralized_conflicts= case @conflict_logging
when 1 then 0
when 2 then 1
else 1
end,
allow_subscription_copy= @allow_subscription_copy,
allow_synctoalternate= @allow_synctoalternate,
replicate_ddl= @replicate_ddl,
automatic_reinitialization_policy= @automatic_reinitialization_policy
where pubid = @pubid_local
if @@error <> 0 return 1

update dbo.sysmergesubscriptions set pubid= @pubid, replicastate= newid() where pubid = @pubid_local
if @@error <> 0 return 1

update dbo.sysmergesubscriptions set subid = @pubid where subid = @pubid_local
if @@error <> 0 return 1

update dbo.MSmerge_replinfo set repid = @pubid where repid = @pubid_local
if @@error <> 0 return 1

execute @retcode= sys.sp_MSrepl_ddl_triggers @type='merge', @mode='add'
if @@error <> 0 or @retcode <> 0 return (1)

return 0

No comments:

Post a Comment

Total Pageviews