May 29, 2012

sp_MSsetreplicastatus (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


sys.sp_MSsetreplicastatus(uniqueidentifier @subid
, int @status_value)


create procedure sys.sp_MSsetreplicastatus
(@subid uniqueidentifier,
@status_value int
) AS

-- Check to see if current publication has permission
declare @retcode int

exec @retcode = sys.sp_MSrepl_PAL_rolecheck @repid = @subid
if (@retcode <> 0) or (@@error <> 0)
return 1

if object_id(N'dbo.sysmergesubscriptions','U') is null
return 0

IF EXISTS (select subid from dbo.sysmergesubscriptions where subid=@subid)
update dbo.sysmergesubscriptions set status = @status_value,
cleanedup_unsent_changes = case when @status_value=1 then 0 else cleanedup_unsent_changes end
WHERE subid=@subid
if @@ERROR<>0 return (1)

if @status_value = 1
-- update the publisher replica row's cleanedup_unsent_changes as well.
update dbo.sysmergesubscriptions set cleanedup_unsent_changes = 0
WHERE subid = (select top 1 pubid from dbo.sysmergesubscriptions where subid = @subid)
if @@ERROR<>0 return (1)

update dbo.MSmerge_replinfo set resync_gen=-1 WHERE repid=@subid
if @@ERROR<>0 return (1)
return (0)

No comments:

Post a Comment

Total Pageviews