Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_dropmergealternatepublisher

  No additional text.


Syntax
create procedure sys.sp_dropmergealternatepublisher (
	@publisher					sysname,					/* Publisher server */
	@publisher_db				sysname,					/* Publisher database */
	@publication				sysname,					/* Publication name */
	@alternate_publisher		sysname,					/* Alternate publisher */
	@alternate_publisher_db		sysname,					/* Alternate publisher_db */
	@alternate_publication		sysname						/* Alternate publication */
	) AS

	SET NOCOUNT ON
	declare @retcode				int
	declare @subid					uniqueidentifier
	declare @alternate_subid		uniqueidentifier
	declare @pubid                  uniqueidentifier
	
	/*
	** Security Check
	*/
	EXEC @retcode = sys.sp_MSreplcheck_publish
	IF @@ERROR <> 0 or @retcode <> 0
		return (1)

	/* Check is there is an invalid attempt to drop the default publiser/publisher_db/publication */
	if (LOWER(@publisher) = LOWER(@alternate_publisher)) AND
		(@publisher_db = @alternate_publisher_db) AND
		(@publication = @alternate_publication)
		begin
			RAISERROR(21252, 11, -1,  @alternate_publisher, @alternate_publisher_db, @alternate_publication)
			return (1)
		end

	/*
	** Select the main publication's pubid and subid
	*/
	select @pubid = pubid from dbo.sysmergepublications	
				where name = @publication and
					LOWER(publisher collate database_default) = LOWER(@publisher collate database_default) and
					publisher_db = @publisher_db
	if @pubid is NULL
	begin
		raiserror (20026, 11, -1, @publication)
		return (1)
	end
	
	-- this subid should really be equal to @pubid
	select @subid = subid from dbo.sysmergesubscriptions
		where LOWER(subscriber_server) collate database_default = LOWER(@publisher) collate database_default and
		db_name = @publisher_db and
		pubid = @pubid and
		status <> 7 -- REPLICA_STATUS_BeforeRestore

    -- check if we know about the publication
    -- we know of the publication if there is an entry in sysmergepublications corresponding to it
    -- the values of @alternate_subid should be same as 'alternate_pubid' in sysmergepublications
	select @alternate_subid = s.subid
	    from dbo.sysmergesubscriptions s, dbo.sysmergepublications p
		where p.name = @alternate_publication and
			  LOWER(p.publisher) collate database_default = LOWER(@alternate_publisher) collate database_default and
			  p.publisher_db = @alternate_publisher_db and
			  p.pubid = s.pubid and
			  s.subid = s.pubid and
			  s.status <> 7 -- REPLICA_STATUS_BeforeRestore
	IF @subid is NULL or @alternate_subid IS NULL
	BEGIN
		RAISERROR(21216, 11, -1,  @alternate_publisher, @alternate_publisher_db, @alternate_publication)
		RETURN (1)
	END

	if exists (select * from MSmerge_altsyncpartners where subid = @subid and alternate_subid = @alternate_subid)
	begin
		delete from MSmerge_altsyncpartners where @subid = subid and alternate_subid = @alternate_subid
		if @@ERROR <> 0 or @@rowcount <> 1
		BEGIN
			GOTO FAILURE
		END
	end				
	return (0)

FAILURE:
	RAISERROR(21251, 11, -1,  @alternate_publisher, @alternate_publisher_db, @alternate_publication)
	RETURN (1)

 
Last revision 2008RTM
See also

  sp_MSdrop_rladmin (Procedure)
       



News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash