June 13, 2012

sp_unsubscribe (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_unsubscribe(nvarchar @publication
, nvarchar @article)

MetaData:

 create procedure sys.sp_unsubscribe (  
@publication sysname = NULL, -- publication name --
@article sysname = NULL -- article name --
) AS

-- New 7.0 sp_dropsubscription parameters
DECLARE @subscriber sysname
DECLARE @destination_db sysname
DECLARE @retcode int

SET NOCOUNT ON

-- sp_unsubscribe has to be callled from a remote subscriber
-- If not, we state that it is unsupported
SELECT @subscriber = @@REMSERVER
IF @subscriber IS NULL
BEGIN
RAISERROR (21023, 16, -1,'sp_unsubscribe')
RETURN(1)
END

-- 6.5 didn't support having multiple databases on the same subscriber
-- subscribing to the same publication so here, all subscriptions to the
-- same publication will be dropped
SELECT @destination_db = NULL

-- Call sp_dropsubscription to do the real work
EXEC @retcode = sys.sp_dropsubscription @publication = @publication,
@article = @article,
@subscriber = @subscriber,
@destination_db = @destination_db
RETURN @retcode

No comments:

Post a Comment

Total Pageviews