-- Name:
-- sp_IHdroppublication
-- Description:
-- HREPL specific logic for sp_droppublication
-- Security:
-- Internal
-- Returns:
-- Success (0) or failure (1)
-- Owner:
--
CREATE PROCEDURE sys.sp_IHdroppublication
(
@publication sysname,
@publisher sysname,
@publisher_type sysname,
@ad_guidname sysname OUTPUT,
@logreaderAgent bit OUTPUT
)
AS
BEGIN
DECLARE @retcode int,
@pubid int
/*
** Parameter Check: @publication.
** The @publication name must conform to the rules for identifiers.
*/
IF @publication IS NULL
BEGIN
RAISERROR (14043, 16, -1, '@publication', 'sp_IHdroppublication')
RETURN (1)
END
-- Verify publication exists
SELECT @pubid = sys.fn_MSrepl_getpubid(@publication, @publisher, @publisher_type)
IF (@pubid IS NULL)
BEGIN
RAISERROR (20026, 11, -1, @publication)
RETURN (1)
END
/*
** Parameter Check: @publisher.
** The @publication name must conform to the rules for identifiers.
*/
IF @publisher IS NULL
BEGIN
RAISERROR (14043, 16, -1, '@publisher', 'sp_IHdroppublication')
RETURN (1)
END
EXECUTE @retcode = dbo.sp_validname @publisher
IF @retcode <> 0
RETURN (1)
-- determine if we have a logreader agent
IF EXISTS (SELECT * FROM IHpublications where repl_freq = 0)
SELECT @logreaderAgent = 0
ELSE
SELECT @logreaderAgent = 1
-- Get guidname before we delete the publication
SELECT @ad_guidname = ad_guidname
FROM IHpublications
WHERE pubid = @pubid
IF @@ERROR <> 0
RETURN (1)
-- delete the publication from the distributor
DELETE IHpublications
WHERE pubid = @pubid
IF @@ERROR <> 0
RETURN (1)
END