June 7, 2012

sp_reinitsubscription (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_reinitsubscription(nvarchar @publication
, nvarchar @article
, nvarchar @subscriber
, nvarchar @destination_db
, bit @for_schema_change
, nvarchar @publisher
, bit @ignore_distributor_failure
, bit @invalidate_snapshot)

MetaData:

   
create procedure sys.sp_reinitsubscription
(
@publication sysname = 'all',
@article sysname = 'all',
@subscriber sysname,
@destination_db sysname = 'all',
@for_schema_change bit = 0,
@publisher sysname = NULL,
@ignore_distributor_failure bit = 0,
@invalidate_snapshot bit = 0
)
AS
BEGIN
DECLARE @cmd nvarchar(4000)
DECLARE @retcode int
DECLARE @distributor sysname
DECLARE @distribdb sysname
DECLARE @publisher_type sysname

SET NOCOUNT ON

SET @retcode = 0

EXEC @retcode = sys.sp_MSrepl_getpublisherinfo @publisher = @publisher,
@rpcheader = @cmd OUTPUT,
@publisher_type = @publisher_type OUTPUT,
@skipSecurityCheck = 1

IF @retcode <> 0
RETURN (@retcode)

-- Add sp
SET @publisher = UPPER(@publisher) COLLATE DATABASE_DEFAULT
set @cmd = @cmd + N'sys.sp_MSrepl_reinitsubscription'

-- Get distributor info
EXEC @retcode = sys.sp_MSrepl_getdistributorinfo @publisher = @publisher,
@rpcsrvname = @distributor OUTPUT,
@distribdb = @distribdb OUTPUT

IF (@retcode <> 0 OR @@ERROR <> 0 OR @distribdb IS NULL or @distributor IS NULL) and @ignore_distributor_failure = 0
BEGIN
RAISERROR (14071, 16, -1)
RETURN (1)
END

EXEC @retcode = @cmd
@publication,
@article,
@subscriber,
@destination_db,
@for_schema_change,
@distributor,
@distribdb,
@publisher,
@publisher_type,
@ignore_distributor_failure,
@invalidate_snapshot

RETURN (@retcode)
END

No comments:

Post a Comment

Total Pageviews