SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Repl_DropArticlePeer]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure [dbo].[Repl_DropArticlePeer] GO /*对等复制删除Article EXEC LS_DropArticlePeer 'testrepl' */ CREATE PROCEDURE Repl_DropArticlePeer @article AS sysname AS BEGIN IF ISNULL(@article,'') = '' BEGIN RETURN END DECLARE @publication AS sysname; SET @publication =DB_NAME(); --SET @article = N'testRepl' --删除对应订阅 IF @@SERVERNAME = 'DataBaseC' --在哪台机器上运行,就不删除自己 BEGIN --exec sp_dropsubscription @publication = @publication, @article = @article, @subscriber = 'databasec' exec sp_dropsubscription @publication =@publication, @article =@article, @subscriber = 'DataBaseD' exec sp_dropsubscription @publication = @publication, @article = @article, @subscriber = 'sqlcluster' END ELSE IF @@SERVERNAME = 'DataBaseD' BEGIN exec sp_dropsubscription @publication = @publication, @article = @article, @subscriber = 'databasec' --exec sp_dropsubscription @publication =@publication, @article =@article, @subscriber = 'DataBaseD' exec sp_dropsubscription @publication = @publication, @article = @article, @subscriber = 'sqlcluster' END ELSE IF @@SERVERNAME = 'SQLCLUSTER' BEGIN exec sp_dropsubscription @publication = @publication, @article = @article, @subscriber = 'databasec' exec sp_dropsubscription @publication =@publication, @article =@article, @subscriber = 'DataBaseD' --exec sp_dropsubscription @publication = @publication, @article = @article, @subscriber = 'sqlcluster' END EXEC sp_droparticle @publication = @publication, @article = @article, @force_invalidate_snapshot = 1; END