May 16, 2012

sp_MShelpsummarypublication (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_MShelpsummarypublication(nvarchar @oename
, nvarchar @oetype)

MetaData:

   
--
-- Name:
-- sp_MShelpsummarypublication
--
-- Description:
-- Called by Object Explorer to populate the Summary Page
-- for a publication
--
-- Security:
-- Public, PAL access
--
-- Returns:
-- 0 : success
-- 1 : failure
--

CREATE PROCEDURE sys.sp_MShelpsummarypublication
(
@oename nvarchar(260),
@oetype nvarchar(100)
)
AS
BEGIN
DECLARE @cmd nvarchar(1000),
@publication sysname,
@publisher_db sysname,
@publisher_type sysname,
@pos_pubname int,
@pos_pubtype int,
@retcode int

-- Verify oename parameter
IF (@oename is null OR LEN(@oename) = 0)
BEGIN
RAISERROR(7801, 16, -1, @oename)
RETURN 1
END

SET @pos_pubname = PATINDEX(N'%:%', @oename)
SET @pos_pubtype = PATINDEX(N'%(%)', @oename)

SELECT @publication = LEFT(@oename, @pos_pubname - 1),
@publisher_db = CASE WHEN @pos_pubtype > 0
THEN SUBSTRING(@oename, @pos_pubname + 1, @pos_pubtype - @pos_pubname - 1)
ELSE SUBSTRING(@oename, @pos_pubname + 1, LEN(@oename) - @pos_pubname)
END,
@publisher_type = CASE WHEN @pos_pubtype > 0
THEN SUBSTRING(@oename, @pos_pubtype + 1, LEN(@oename) - @pos_pubtype - 1)
ELSE NULL
END

IF (@publication IS NULL OR LEN(@publication) = 0 OR @publisher_db IS NULL OR LEN(@publisher_db) = 0)
BEGIN
RAISERROR(21423, 16, -1, @publication) -- The security check is later, so we want to raise the more generic error
RETURN 1
END

--
-- execute the actual proc in publishing db
-- security check is done inside
--

IF @publisher_type IS NULL OR LEN(@publisher_type) = 0
BEGIN
-- SQL Server publication
SELECT @cmd = QUOTENAME(RTRIM(@publisher_db)) + '.sys.sp_publicationsummary'
EXEC @retcode = @cmd @publication = @publication
END
ELSE
BEGIN
-- HREPL publication
EXEC @retcode = sys.sp_publicationsummary @publication = @publication,
@publisher = @publisher_db
END

RETURN @retcode
END

No comments:

Post a Comment

Total Pageviews