May 25, 2012

sp_MSrepl_snapshot_helppublication (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_MSrepl_snapshot_helppublication(nvarchar @publication
, nvarchar @publisher)

MetaData:

 create procedure sys.sp_MSrepl_snapshot_helppublication  
(
@publication sysname,
@publisher sysname
)
AS
BEGIN
SET NOCOUNT ON

--
-- Declarations.
--

DECLARE @pubid int
DECLARE @has_subscription bit
DECLARE @retcode int
DECLARE @publish_bit int

SELECT @publish_bit = 1

--
-- Security Check
--
EXEC @retcode = sys.sp_MSreplcheck_publish
IF @@ERROR <> 0 or @retcode <> 0
return (1)


-- Parameter Check: @publisher
IF @publisher IS NULL
BEGIN
RAISERROR (14043, 16, -1, '@publisher', 'sp_MSrepl_snapshot_helppublication')
RETURN (1)
END

-- Parameter Check: @publication
IF @publication IS NULL
BEGIN
RAISERROR (14043, 16, -1, '@publication', 'sp_MSrepl_snapshot_helppublication')
RETURN (1)
END

EXECUTE @retcode = dbo.sp_validname @publication
IF @retcode <> 0
RETURN (1)

SELECT 'pubid' = sp.pubid,
'name' = sp.name,
'restricted' = 0,
'status' = sp.status,
-- using 'task' is for backward compatibilty
'task' = convert(int, 1),
'replication frequency' = sp.repl_freq,
'synchronization method' = sp.sync_method,
'description' = sp.description,
'immediate_sync' = sp.immediate_sync,
'enabled_for_internet' = sp.enabled_for_internet,
'allow_push' = sp.allow_push,
'allow_pull' = sp.allow_pull,
'allow_anonymous' = sp.allow_anonymous,
'independent_agent' = sp.independent_agent,
'immediate_sync_ready' = sp.immediate_sync_ready,
-- SyncTran
'allow_sync_tran' = sp.allow_sync_tran,
'autogen_sync_procs' = sp.autogen_sync_procs,
'snapshot_jobid' = sp.snapshot_jobid,
'retention' = sp.retention,
'has subscription' = CASE WHEN EXISTS
(
SELECT *
FROM IHsubscriptions
WHERE article_id IN
(
SELECT article_id
FROM IHarticles
WHERE publication_id = sp.pubid
)
)
THEN 1 ELSE 0 END,
'allow_queued_tran' = sp.allow_queued_tran,
-- Portable snapshot
'snapshot_in_defaultfolder' = sp.snapshot_in_defaultfolder,
'alt_snapshot_folder' = sp.alt_snapshot_folder,
-- Pre/post-snapshot commands
'pre_snapshot_script' = sp.pre_snapshot_script,
'post_snapshot_script' = sp.post_snapshot_script,
-- Snapshot compression
'compress_snapshot' = sp.compress_snapshot,
-- Post 7.0 ftp support
'ftp_address' = sp.ftp_address,
'ftp_port' = sp.ftp_port,
'ftp_subdirectory' = sp.ftp_subdirectory,
'ftp_login' = sp.ftp_login,
'ftp_password' = sys.fn_repldecryptver4(sp.ftp_password),
'allow_dts' = sp.allow_dts,
'allow_subscription_copy' = sp.allow_subscription_copy,
-- 7.5 Queued updates
'centralized_conflicts' = NULL,
'conflict_retention' = 14,
'conflict_policy' = NULL,
'queue_type' = NULL,
'backward_comp_level' = sp.backward_comp_level,
'publish_to_AD' = CASE
WHEN sp.ad_guidname IS NULL
THEN 0 ELSE 1 END
FROM syspublications sp,
MSpublications msp,
master.dbo.sysservers ss
WHERE sp.pubid = msp.publication_id
AND msp.publisher_id = ss.srvid
AND UPPER(ss.srvname collate database_default) = UPPER(@publisher) collate database_default
AND ((sp.name = @publication) or (@publication = N'%'))
ORDER BY sp.name
IF @@ERROR <> 0 RETURN 1

RETURN (0)
END

sp_MSrepl_subscription_rowset (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_MSrepl_subscription_rowset(nvarchar @subscriber
, int @agent_id
, int @agent_type)

MetaData:

 create procedure sys.sp_MSrepl_subscription_rowset  
(
@subscriber sysname,
@agent_id int,
@agent_type int = 0
)
AS
BEGIN
DECLARE @retcode int
DECLARE @subscriber_provider sysname

SELECT @subscriber_provider = NULL

-- Security check: sysadmin/dbo/PAL only
EXEC @retcode = sys.sp_MScheck_pull_access @agent_id = @agent_id,
@agent_type = @agent_type
IF @@error <> 0 or @retcode <> 0
RETURN 1

-- Query the MSdistribution_agents entry for the subscriber provider
SELECT @subscriber_provider = ma.subscriber_provider
FROM MSdistribution_agents ma, master.dbo.sysservers ss
WHERE UPPER(ss.srvname) = UPPER(@subscriber) collate database_default
AND ma.subscriber_id = ss.srvid
AND ma.id = @agent_id

IF @@error <> 0
RETURN 1

-- If the subscriber_provider from the MSdistribution_agents table is
-- NULL, we either have a downlevel publisher, or yukon security is not
-- enabled. In both cases, we need to call sp_MSrepl_linkedserver_rowset
-- to generate the rowset.
IF ISNULL(@subscriber_provider, N' ') = N' '
BEGIN
exec @retcode = sys.sp_MSrepl_linkedservers_rowset @srvname = @subscriber,
@agent_id = @agent_id,
@agent_type = @agent_type
IF @@error <> 0 or @retcode <> 0
BEGIN
RETURN 1
END

RETURN 0

END

-- Query the MSdistribution_agents entry for the subscriber information
SELECT SUB_NAME = ss.srvname,
SUB_PRODUCT = ss.srvproduct,
SUB_PROVIDERNAME = ma.subscriber_provider,
SUB_DATASOURCE = ma.subscriber_datasrc,
SUB_PROVIDERSTRING = ma.subscriber_provider_string,
SUB_LOCATION = ma.subscriber_location,
SUB_CATALOG = ma.subscriber_catalog
FROM MSdistribution_agents ma, master.dbo.sysservers ss
WHERE UPPER(ss.srvname) = UPPER(@subscriber) collate database_default
AND ma.subscriber_id = ss.srvid
AND ma.id = @agent_id

IF @@error <> 0
BEGIN
RETURN 1
END

RETURN 0
END

sp_MSreplcheck_subscribe (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_MSreplcheck_subscribe()

MetaData:

 create procedure sys.sp_MSreplcheck_subscribe  
as
begin
--
-- Only the System Administratr (SA) or the Database Owner (dbo)
-- can subscribe from the subscribing database.
--
-- Do the sysadmin check first as it is 4 times more efficient
-- than is_member call and reduces performance overhead in case
-- the user has sysadmin privileges
--
if is_srvrolemember('sysadmin') = 1 or is_member ('db_owner') = 1
begin
return (0)
end
else
begin
raiserror (21050, 14, -1)
return (1)
end
end

sp_MSrepl_enumsubscriptions (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_MSrepl_enumsubscriptions(nvarchar @publication
, nvarchar @publisher
, bit @reserved)

MetaData:

   
--
-- Name:
-- sp_MSrepl_enumsubscriptions
--
-- Description:
-- Enumerate subscriptions on a database
--
-- Returns:
-- 0 == Failed
-- 1 == Succeed
--
-- Security:
-- public, db_owner check
-- Requires Certificate signature for catalog access
--
-- Notes:
-- Used by the UI to generate a list of subscriptions
--
CREATE PROCEDURE sys.sp_MSrepl_enumsubscriptions
(
@publication sysname,
@publisher sysname = NULL ,
@reserved bit = 0 -- Set to 1 when used by UI
)
AS
BEGIN
set nocount on
DECLARE @retcode int
,@dbname sysname
,@hasadminaccess bit
,@login_name sysname
,@category int
,@fpublished bit

--
-- Security Check.
-- Part of the query to gather the list of publications uses security context
-- Optimization done for syadmin or dbowner
--
select @dbname = db_name()
,@hasadminaccess = case when (is_member('db_owner') = 1 OR is_srvrolemember('sysadmin') = 1) then 1 else 0 end
,@login_name = suser_sname(suser_sid())

-- Verify database is published
-- Have put the code from fn_MSrepl_ispublished inline for faster processing
-- If fn_MSrepl_ispublished() is updated - this code block should be updated as well
SELECT @category = category
FROM master.sys.sysdatabases
WHERE name = @dbname

IF (@category IS NOT NULL)
BEGIN
-- We have entry for this db_name in sysdatabases
-- Is this database a distributor?
IF (@category & 16 = 16)
BEGIN
-- DB is a distributor - is it used for HREPL publisher?
IF OBJECT_ID(N'msdb.dbo.MSdistpublishers') IS NOT NULL
BEGIN
IF EXISTS
(
SELECT name
FROM msdb.dbo.MSdistpublishers
WHERE distribution_db = @dbname
AND publisher_type != N'MSSQLSERVER'
)
BEGIN
SELECT @fpublished = 1
END
END
END
ELSE
BEGIN
-- Check if this database is a transactional or merge publisher
IF (@category & 1 = 1 OR @category & 4 = 4)
BEGIN
SELECT @fpublished = 1
END
END
END -- @category not null
--
-- If the database is not published - return
--
IF (@fpublished = 0)
RETURN (0)
--
-- set publisher
--
if (@publisher IS NULL)
select @publisher = publishingservername()
--
-- Create temp table if needed
--
if (@reserved = 0)
begin
create table #tmp_pubsubscriptions
(
publisher sysname not null,
publisher_db sysname not null,
publisher_type sysname not null,
publication sysname not null,
publication_type int not null,
subscription_name nvarchar(258) not null,
subscriber sysname not null,
subscriber_db sysname not null,
subscription_type int not null,
priority float(8) not null default 0.0
)
end
-- Get snapshot or transactional subscriptions
if (object_id(N'dbo.syssubscriptions') is not null)
BEGIN
IF (@category & 16 != 16)
BEGIN
-- SQL publication db
INSERT INTO #tmp_pubsubscriptions
(
publisher,
publisher_db,
publisher_type,
publication,
publication_type,
subscription_name,
subscriber,
subscriber_db,
subscription_type
)
SELECT DISTINCT
@publisher,
@dbname,
N'MSSQLSERVER',
pub.name,
pub.repl_freq,
sub.srvname collate database_default + N':' + sub.dest_db,
sub.srvname,
sub.dest_db,
sub.subscription_type
FROM dbo.syssubscriptions as sub
join dbo.sysextendedarticlesview as art on sub.artid = art.artid
join dbo.syspublications as pub on art.pubid = pub.pubid
WHERE pub.name = @publication
AND (@hasadminaccess = 1 OR sub.login_name = @login_name)
and sub.srvname is not null and len(sub.srvname) > 0
-- GROUP BY srv.name, sub.dest_db, pub.name, pub.repl_freq, sub.subscription_type
END
ELSE
BEGIN
-- Heterogeneous subscriptions
INSERT INTO #tmp_pubsubscriptions
(
publisher,
publisher_db,
publisher_type,
publication,
publication_type,
subscription_name,
subscriber,
subscriber_db,
subscription_type
)
SELECT DISTINCT
pubsrv.name,
pubsrv.name,
msd.publisher_type,
pub.name,
pub.repl_freq,
subsrv.name collate database_default + N':' + sub.dest_db,
subsrv.name,
sub.dest_db,
sub.subscription_type
FROM dbo.syssubscriptions as sub
join sys.servers as subsrv on sub.srvid = subsrv.server_id
join dbo.sysarticles as art on sub.artid = art.artid
join dbo.syspublications as pub on art.pubid = pub.pubid
join dbo.MSpublications as msp on pub.pubid = msp.publication_id
join sys.servers as pubsrv on pubsrv.server_id = msp.publisher_id
join msdb.dbo.MSdistpublishers as msd on msd.name = pubsrv.name
WHERE pub.name = @publication
AND pubsrv.name = @publisher
AND (@hasadminaccess = 1 OR sub.login_name = @login_name)
END
END

-- Get merge subscriptions
if (object_id(N'dbo.sysmergesubscriptions') is not null)
BEGIN
INSERT INTO #tmp_pubsubscriptions
(
publisher,
publisher_db,
publisher_type,
publication,
publication_type,
subscription_name,
subscriber,
subscriber_db,
subscription_type,
priority
)
SELECT DISTINCT
pub.publisher,
pub.publisher_db,
N'MSSQLSERVER',
pub.name,
2,
sub.subscriber_server + N':' + sub.db_name,
sub.subscriber_server,
sub.db_name,
sub.subscription_type,
sub.priority
FROM dbo.sysmergesubscriptions as sub
join dbo.sysmergepublications as pub on pub.pubid = sub.pubid
join dbo.MSmerge_replinfo as rep on rep.repid = sub.subid
WHERE sub.status != 2
AND sub.subscriber_type <> 3
AND sub.subid != sub.pubid
AND pub.name = @publication
AND (@hasadminaccess = 1 OR rep.login_name = @login_name)
END

-- Return result set if needed
if (@reserved = 0)
begin
SELECT *
FROM #tmp_pubsubscriptions
ORDER BY publisher, subscriber, subscriber_db
end
-- all done
RETURN (0)
END

sp_MSrepl_check_publisher (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_MSrepl_check_publisher(nvarchar @publisher_type
, nvarchar @publisher
, bit @security_mode
, nvarchar @login
, nvarchar @password
, int @connect_timeout)

MetaData:

   
--
-- Name:
-- sp_MSrepl_check_publisher
--
-- Description:
-- Determine if an ad-hoc datasource is currently published.
--
-- Returns:
-- Result set:
-- Distributor that owns publisher
-- NULL if not published
--
-- Security:
-- public
--
-- Notes:
-- Used by the UI
-- Connect time out is measure in seconds (default of 60)
--

CREATE PROCEDURE sys.sp_MSrepl_check_publisher
(
@publisher_type sysname,
@publisher sysname,
@security_mode bit = 1,
@login nvarchar(255) = null,
@password nvarchar(255) = null,
@connect_timeout int = 60
)
AS
BEGIN
DECLARE @retcode int

IF UPPER(@publisher_type) IN ('ORACLE', 'ORACLE GATEWAY')
BEGIN
EXEC sys.sp_ORAcheckpublisher @publisher,
@security_mode,
@login,
@password,
@connect_timeout
END
ELSE
BEGIN
RAISERROR(21645, 16, -1, @publisher_type)
RETURN (1)
END
END

sp_MSrepl_raiserror (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_MSrepl_raiserror(nvarchar @agent
, nvarchar @agent_name
, int @status
, nvarchar @message
, nvarchar @subscriber
, nvarchar @publication
, nvarchar @article)

MetaData:

 create procedure sys.sp_MSrepl_raiserror  
(
@agent sysname,
@agent_name nvarchar(100),
@status int,
@message nvarchar(255),
@subscriber sysname = NULL,
@publication sysname = NULL,
@article sysname = NULL
)
as
begin
if @status = 2 -- Succeeded
raiserror (14150, 10, -1, @agent, @agent_name, @message)
else if @status = 5 -- Retry Failure
raiserror (14152, 10, -1, @agent, @agent_name, @message)
else if @status = 6 -- Failure
begin
raiserror (14151, 18, -1, @agent, @agent_name, @message)
end
else if @status = 7
begin
raiserror (20574, 10, -1, @subscriber, @article, @publication)
end
else if @status = 8
begin
raiserror (20575, 10, -1, @subscriber, @article, @publication)
end
else if @status = 9
begin
raiserror (14158, 10, -1, @agent, @agent_name, @message)
end
end

sp_MSrepl_enumpublications (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_MSrepl_enumpublications(bit @reserved)

MetaData:

   
--
-- Name:
-- sp_MSrepl_enumpublications
--
-- Description:
-- Enumerate publications on a database
--
-- Returns:
-- 0 == Failed
-- 1 == Succeed
--
-- Security:
-- public, PAL access for tran publications, dbo check for merge publications
-- Requires Certificate signature for catalog access
--
-- Notes:
-- Used by the UI to generate a list of pubications
--
-- Publication type:
-- 0 == TRAN
-- 1 == SNAPSHOT
-- 2 == MERGE
--
CREATE PROCEDURE sys.sp_MSrepl_enumpublications
(
@reserved bit = 0 -- Set to 1 when used by UI
)
AS
BEGIN
SET NOCOUNT ON
DECLARE @retcode int
,@pubid int
,@pubname sysname
,@username sysname
,@OPT_ENABLED_FOR_P2P int
,@category int
,@skippalcheck bit
,@dbname sysname
,@fpublished bit
,@OPT_ENABLED_FOR_P2PCONFLICTDETECTION int

--
-- initialize
--
select @dbname = db_name()
,@OPT_ENABLED_FOR_P2P = 0x1
,@username = SUSER_SNAME()
,@fpublished = 0
,@OPT_ENABLED_FOR_P2PCONFLICTDETECTION = 0x08
--
-- Verify database is published
-- Have put the code from fn_MSrepl_ispublished inline for faster processing
-- If fn_MSrepl_ispublished() is updated - this code block should be updated as well
--
SELECT @category = category
FROM master.sys.sysdatabases
WHERE name = @dbname

IF (@category IS NOT NULL)
BEGIN
-- We have entry for this db_name in sysdatabases
-- Is this database a distributor?
IF (@category & 16 = 16)
BEGIN
-- DB is a distributor - is it used for HREPL publisher?
IF OBJECT_ID(N'msdb.dbo.MSdistpublishers') IS NOT NULL
BEGIN
IF EXISTS
(
SELECT name
FROM msdb.dbo.MSdistpublishers
WHERE distribution_db = @dbname
AND publisher_type != N'MSSQLSERVER'
)
BEGIN
SELECT @fpublished = 1
END
END
END
ELSE
BEGIN
-- Check if this database is a transactional or merge publisher
IF (@category & 1 = 1 OR @category & 4 = 4)
BEGIN
SELECT @fpublished = 1
END
END
END -- @category not null
--
-- If the database is not published - return
--
IF (@fpublished = 0)
BEGIN
RETURN (0)
END
--
-- Security Check.
-- Skip PAL check if DBO
-- For PAL check - Part of the query to gather the list of publications uses security context
--
select @skippalcheck = case when (is_member ('db_owner') = 1 OR is_srvrolemember('sysadmin') = 1) then 1 else 0 end
if (@skippalcheck = 0)
begin
DECLARE @accessiblepubs TABLE
(
pubid int
)
end
--
-- Create local temp table if needed
--
if (@reserved = 0)
begin
create TABLE #tmp_publications
(
publisher sysname not null,
dbname sysname not null,
publication sysname not null,
publisher_type sysname not null,
publication_type int not null,
description nvarchar(255) null,
allow_queued bit default 0 NOT NULL,
enabled_for_p2p bit default 0 NOT NULL,
enabled_for_p2pconflictdetection bit default 0 NOT NULL
)
end
--
-- Get snapshot or transactional publications
--
IF object_id(N'dbo.syspublications') IS NOT NULL
BEGIN
if (@skippalcheck = 0)
begin
-- Catalog accessible pub ids
DECLARE #hC CURSOR LOCAL FAST_FORWARD FOR
SELECT pubid, name
FROM dbo.syspublications

OPEN #hC
FETCH #hC INTO @pubid, @pubname
WHILE (@@fetch_status <> -1)
BEGIN
EXEC @retcode = sys.sp_MSreplcheck_pull @publication = @pubname,
@raise_fatal_error = 0,
@given_login = @username
IF (@retcode = 0 AND @@error = 0)
BEGIN
INSERT INTO @accessiblepubs values(@pubid)
END

FETCH #hC INTO @pubid, @pubname
END
CLOSE #hC
DEALLOCATE #hC
end -- if (@skippalcheck = 0)
--
-- Determine if distribution db is being cataloged
--
IF (@category & 16 != 16)
BEGIN
-- SQL Server publication db
INSERT INTO #tmp_publications
(
publisher,
dbname,
publication,
publisher_type,
publication_type,
description,
allow_queued,
enabled_for_p2p,
enabled_for_p2pconflictdetection
)
SELECT publishingservername(),
@dbname,
name,
N'MSSQLSERVER',
repl_freq,
description,
allow_queued_tran,
(options & @OPT_ENABLED_FOR_P2P),
(options & @OPT_ENABLED_FOR_P2PCONFLICTDETECTION)
FROM dbo.syspublications
WHERE @skippalcheck = 1
OR (pubid IN (SELECT pubid FROM @accessiblepubs))
END
ELSE
BEGIN
-- Distribution db - Heterogeneous publications
INSERT INTO #tmp_publications
(
publisher,
dbname,
publication,
publisher_type,
publication_type,
description,
allow_queued,
enabled_for_p2p
)
SELECT ss.srvname,
@dbname, -- distribution db name for enumerator to work
sp.name,
msd.publisher_type,
sp.repl_freq,
sp.description,
sp.allow_queued_tran,
(sp.options & @OPT_ENABLED_FOR_P2P)
FROM dbo.syspublications sp
join dbo.MSpublications msp on sp.pubid = msp.publication_id
join master.dbo.sysservers ss on msp.publisher_id = ss.srvid
join msdb.dbo.MSdistpublishers msd on msd.name = ss.srvname
WHERE @skippalcheck = 1
OR (pubid IN (SELECT pubid FROM @accessiblepubs))
END
END -- IF object_id(N'dbo.syspublications') IS NOT NULL
--
-- Get merge publications
--
IF object_id(N'dbo.sysmergepublications') IS NOT NULL
BEGIN
INSERT INTO #tmp_publications
(
publisher,
dbname,
publication,
publisher_type,
publication_type,
description
)
SELECT publisher,
publisher_db,
name,
N'MSSQLSERVER',
2,
description
FROM dbo.sysmergepublications
WHERE (@skippalcheck = 1 OR {fn ISPALUSER(pubid)} = 1)
and publisher_db = @dbname
and UPPER(publisher) = UPPER(publishingservername())
END -- object_id(N'dbo.sysmergepublications') IS NOT NULL
--
-- Return result set if we created local table
--
if (@reserved = 0)
begin
SELECT *
FROM #tmp_publications
ORDER BY publisher, dbname, publication
end
--
-- all done
--
RETURN (0)
END

sp_MSreset_attach_state (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_MSreset_attach_state(nvarchar @publisher
, nvarchar @publisher_db
, nvarchar @publication
, int @subscription_type)

MetaData:

 create procedure sys.sp_MSreset_attach_state   
(
@publisher sysname, -- publishing server name
@publisher_db sysname, -- publishing database name. If NULL then same as current db
@publication sysname, -- publication name,
@subscription_type int
)
AS
BEGIN
set nocount on
declare @retcode int
,@agent_id int

--
-- Security Check
--
EXEC @retcode = sys.sp_MSreplcheck_subscribe
IF @@ERROR <> 0 or @retcode <> 0
RETURN(1)
--
-- For non independent agent publications
--
if @publication is null or @publication = ''
select @publication = 'ALL'
--
-- complete the operation in a transaction
--
begin transaction
--
-- Processing specific to Queued updating subscriptions
--
select @agent_id = id
from dbo.MSsubscription_agents
where UPPER(publisher) = UPPER(@publisher)
and publisher_db = @publisher_db
and publication = @publication
and subscription_type = @subscription_type
and update_mode in (2,3,4,5)
if (@agent_id is not null)
begin
--
-- reinitialize the queue for each article in this subscription
--
declare @artid int
declare #hc_article CURSOR LOCAL FORWARD_ONLY for
select artid
from dbo.MSsubscription_articles
where agent_id = @agent_id
open #hc_article
fetch #hc_article into @artid
while (@@fetch_status != -1)
begin
--
-- we cannot have an NULL article id
--
if (@artid IS NULL)
begin
raiserror(20046, 16, 1)
goto failure
end
--
-- reset the queue
--
exec @retcode = sys.sp_MSreset_queue @publisher, @publisher_db, @publication, @artid
IF (@retcode != 0 or @@ERROR != 0)
begin
raiserror(21465, 16, 1, 'sp_MSreset_queue')
goto failure
end
--
-- fetch next article
--
fetch #hc_article into @artid
end -- while cursor
close #hc_article
deallocate #hc_article
end -- end processing queued subscription
--
-- Update the attach state
--
update MSsubscription_agents
set attach_state = 0
where UPPER(publisher) = UPPER(@publisher)
and publisher_db = @publisher_db
and publication = @publication
and subscription_type = @subscription_type
if (@@error != 0)
goto failure
--
-- All done
-- commit the transaction
--
commit transaction
return (0)
failure:
--
-- Rollback transaction
--
if (@@trancount > 0)
rollback transaction
return (1)
END

sp_MSrequestreenumeration_lightweight (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_MSrequestreenumeration_lightweight(int @tablenick
, uniqueidentifier @rowguid)

MetaData:

 create procedure sys.sp_MSrequestreenumeration_lightweight  
@tablenick int,
@rowguid uniqueidentifier

as
declare @retcode int
declare @err int
declare @rc int
declare @METADATA_ACTION_ForceReenumeration tinyint

set @METADATA_ACTION_ForceReenumeration= 5

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

update dbo.MSmerge_metadataaction_request
set action= @METADATA_ACTION_ForceReenumeration,
generation=null,
changed= sys.fn_MSdayasnumber(getdate())
where tablenick=@tablenick and rowguid=@rowguid

select @err= @@error, @rc=@@rowcount
if @err<>0 return 1
if @rc>0 return 0

insert into dbo.MSmerge_metadataaction_request
(tablenick,
rowguid,
action,
generation,
changed)
values
(@tablenick,
@rowguid,
@METADATA_ACTION_ForceReenumeration,
null,
sys.fn_MSdayasnumber(getdate()))

if @err<>0 return 1
return 0

sp_MSreplupdateschema (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_MSreplupdateschema(nvarchar @object_name)

MetaData:

   
create procedure sys.sp_MSreplupdateschema @object_name nvarchar(517)
as
begin
declare @retcode int
IF @object_name IS NULL
BEGIN
RAISERROR (14043, 16, -1, '@object_name', 'sp_MSreplupdateschema')
RETURN (1)
END

EXEC @retcode = sys.sp_MSreplcheck_publish
IF @@ERROR <> 0 or @retcode <> 0
return (1)

exec sys.sp_replupdateschema @object_name
return 0
end

sp_MSrequestreenumeration (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_MSrequestreenumeration(int @tablenick
, uniqueidentifier @rowguid)

MetaData:

 create procedure sys.sp_MSrequestreenumeration  
@tablenick int,
@rowguid uniqueidentifier
as
declare @retcode int
declare @err int
declare @rc int
declare @METADATA_ACTION_ForceReenumeration tinyint

set @METADATA_ACTION_ForceReenumeration= 5

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

update dbo.MSmerge_metadataaction_request
set action= @METADATA_ACTION_ForceReenumeration,
generation=0,
changed= null
where tablenick=@tablenick and rowguid=@rowguid

select @err= @@error, @rc=@@rowcount
if @err<>0 return 1
if @rc>0 return 0

insert into dbo.MSmerge_metadataaction_request
(tablenick,
rowguid,
action,
generation,
changed)
values
(@tablenick,
@rowguid,
@METADATA_ACTION_ForceReenumeration,
0,
null)

if @err<>0 return 1
return 0

sp_MSreplremoveuncdir (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_MSreplremoveuncdir(nvarchar @dir
, bit @ignore_errors)

MetaData:

 --   
-- Name: sp_MSreplremoveuncdir
--
-- Descriptions:
--
-- Parameters: as defined in create statement
--
-- Returns: 0 - success
-- 1 - Otherwise
--
-- Security: Public procedure invoked via RPC. db_owner check
--
-- Requires Certificate signature for catalog access
--
CREATE PROCEDURE sys.sp_MSreplremoveuncdir
(
@dir nvarchar(260),
@ignore_errors bit = 0
)
as
begin
set nocount on

declare @retcode int
declare @local_dir nvarchar(260)
declare @cmd nvarchar(1000)
declare @machinename sysname
set @retcode = 0
--
-- security check
-- only sysadmin can execute this
--
if (isnull(is_srvrolemember('sysadmin'),0) = 0)
begin
raiserror(14260, 16, -1)
return (1)
end

-- Null\Empty paths == no-op --
if @dir is null or rtrim(@dir) = N''
return (0)

-- Path truncation check --
if len(@dir) = 260
return (0)

--
-- We have to convert UNC to drive, otherwise will get 'Access denied' error in xp_cmdshell
--
select @machinename = convert(sysname, SERVERPROPERTY('machinename'))
EXEC @retcode = master.dbo.sp_MSunc_to_drive @unc_path = @dir,
@local_server = @machinename, @local_path = @local_dir OUTPUT
IF @retcode <> 0 or @@ERROR <> 0
RETURN(1)

--
-- Delete directory in the distributor's directory.
-- On Win9x, we have to use deltree instead
--
declare @platform_nt int
select @platform_nt = 0x1
IF (( platform() & @platform_nt = @platform_nt))
BEGIN
SELECT @cmd = 'if exist "' + sys.fn_escapecmdshellsymbolsremovequotes(@local_dir) collate database_default + '" rmdir /S /Q ' + '"' + sys.fn_escapecmdshellsymbolsremovequotes(@local_dir) collate database_default + '"'
END
ELSE
BEGIN
-- Don't need if exists check on Win9x but we do need
-- to remove the trailing slash
IF SUBSTRING(@local_dir, LEN(@local_dir), 1) = N'\'
BEGIN
SELECT @local_dir = LEFT(@local_dir, LEN(@local_dir)-1)
END
SELECT @cmd = 'deltree /Y ' + '"' + sys.fn_escapecmdshellsymbolsremovequotes(@local_dir) collate database_default + '"'
END

EXECUTE @retcode = master.dbo.xp_cmdshell @cmd, NO_OUTPUT

if @ignore_errors <> 1
begin
if @retcode <> 0 or @@ERROR <> 0
begin
raiserror(20015, 16, -1, @dir)
return(1)
end
end

return (0)
end

sp_MSreplraiserror (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_MSreplraiserror(int @errorid
, nvarchar @param1
, nvarchar @param2)

MetaData:

   
create procedure sys.sp_MSreplraiserror @errorid int, @param1 sysname = null, @param2 sysname= null
as
if @errorid = 20508 raiserror (20508, 11, 1)
else if @errorid = 20509 raiserror (20509, 16, 1)
else if @errorid = 20510 raiserror (20510, 16, 1)
else if @errorid = 20511 raiserror (20511, 16, 1)
else if @errorid = 20512 raiserror (20512, 16, 1)
else if @errorid = 20515 raiserror (20515, 16, 1)
else if @errorid = 20516 raiserror (20516, 16, 1)
else if @errorid = 20504 raiserror (20504, 16, 1)
else if @errorid = 20518 raiserror (20518, 16, 1)
else if @errorid = 20519 raiserror (20519, 16, 1)
else if @errorid = 20520 raiserror (20520, 16, 1)
else if @errorid = 21034 raiserror (21034, 16, 1)
else if @errorid = 21052 raiserror (21052, 16, 1)
else if @errorid = 21054 raiserror (21054, 16, 1)
else if @errorid = 21064 raiserror (21064, 16, 1)
else if @errorid = 21161 raiserror (21161, 16, 1)
else if @errorid = 20598 raiserror (20598, 16, 1)

sp_MSreplcopyscriptfile (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_MSreplcopyscriptfile(nvarchar @directory
, nvarchar @scriptfile)

MetaData:

 --   
-- Name: sp_MSreplcopyscriptfile
--
-- Descriptions:
--
-- Parameters: as defined in create statement
--
-- Returns: 0 - success
-- 1 - Otherwise
--
-- Security: Public procedure invoked via RPC. db_owner check
--
-- Requires Certificate signature for catalog access
--
CREATE PROCEDURE sys.sp_MSreplcopyscriptfile
(
@directory nvarchar(4000),
@scriptfile nvarchar(4000)
)
as
begin
set nocount on

declare @retcode int
declare @cmd nvarchar(4000)
--
-- security check
-- only sysadmin can execute this
--
if (isnull(is_srvrolemember('sysadmin'),0) = 0)
begin
raiserror(14260, 16, -1)
return (1)
end

select @cmd = N'if not exist "' + sys.fn_escapecmdshellsymbolsremovequotes(@directory) collate database_default + '" md "' + sys.fn_escapecmdshellsymbolsremovequotes(@directory) collate database_default + '"'
exec @retcode = master.dbo.xp_cmdshell @cmd, NO_OUTPUT
if(@retcode <> 0)
begin
raiserror(21330, 16, -1, @cmd)
return (1)
end

-- Copy script to distributor
select @cmd = N'copy "' + sys.fn_escapecmdshellsymbolsremovequotes(@scriptfile) collate database_default + N'" "' + sys.fn_escapecmdshellsymbolsremovequotes(@directory) collate database_default + N'"'
exec @retcode = master.dbo.xp_cmdshell @cmd, NO_OUTPUT
if(@retcode <> 0)
begin
raiserror(21331, 16, -1, @cmd)
return (1)
end

return (0)
end

Total Pageviews