June 4, 2012

sp_MSunregistersubscription (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_MSunregistersubscription(nvarchar @publisher
, nvarchar @publisher_db
, nvarchar @publication
, nvarchar @subscriber
, nvarchar @subscriber_db)

MetaData:

   
create procedure sys.sp_MSunregistersubscription
(
@publisher sysname = NULL,
@publisher_db sysname = NULL,
@publication sysname = NULL,
@subscriber sysname = NULL,
@subscriber_db sysname = NULL
)
AS
BEGIN
--
-- Drop the corresponding registry entry for MobileSync
--
declare @enabled int
declare @retcode int
declare @regkey nvarchar(1000)

select @retcode = 0

exec @retcode = sys.sp_MSreplcheck_subscribe

if @@error <> 0 or @retcode <> 0
BEGIN
RETURN 1
END

-- Mark enabled_for_syncmgr bit before trying to delete the key
-- If the row exists in MSreplication_properties table,
-- set enabled_for_syncmgr bit
-- The logic need to be here because UI call this sp directly.
IF OBJECT_ID('MSsubscription_properties') IS NOT NULL
BEGIN
UPDATE MSsubscription_properties
SET enabled_for_syncmgr = 0
WHERE UPPER(publisher) = UPPER(@publisher)
AND publisher_db = @publisher_db
AND publication = @publication

IF @@ERROR <> 0
RETURN 1
END

-- regdelete returns 'Access Denied' message if key does not exist; check before delete
EXEC sys.sp_MSsubscription_enabled_for_syncmgr @publisher,
@publisher_db,
@publication,
@subscriber,
@subscriber_db,
@enabled OUT,
@regkey OUT
IF @@ERROR <> 0
RETURN 1

IF @enabled = 1 AND LEN(@regkey) > 0
BEGIN
EXECUTE @retcode = master.dbo.xp_regdeletekey 'HKEY_LOCAL_MACHINE', @regkey

IF @@error != 0 OR @retcode != 0
BEGIN
return 1
END
END

return 0
END

No comments:

Post a Comment

Total Pageviews