Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MScleanup_conflict_table

  No additional text.


Syntax
create procedure sys.sp_MScleanup_conflict_table
AS
BEGIN
    set nocount on
	declare @retcode			int
	declare @pubid				uniqueidentifier
	declare @conflict_retention int
			,@conflict_table	nvarchar(542)
			,@cmd				nvarchar(4000)
			,@tranpubid			int

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

	
	-- merge cleanup
	
	if object_id('sysmergepublications') is not NULL
	begin
		declare PC CURSOR LOCAL FAST_FORWARD for select DISTINCT pubid, conflict_retention
			from dbo.sysmergepublications where LOWER(publisher)=LOWER(publishingservername()) and publisher_db=db_name() and conflict_retention>0
		open PC
		fetch PC into @pubid, @conflict_retention
		while (@@fetch_status<>-1)
		begin
			exec @retcode = sys.sp_MScleanup_conflict @pubid, @conflict_retention
			if @@ERROR<>0 or @retcode<>0
			begin
				close PC
				deallocate PC
				return (1)
			end
			fetch next from PC into	 @pubid, @conflict_retention
		end
		close PC
		deallocate PC
	end

	
	-- tran cleanup
	
	if object_id('syspublications') is not NULL
	begin
		
		-- do for each conflict table in each publication
		
		declare hCftTab cursor LOCAL FAST_FORWARD for
			select a.pubid, a.conflict_retention
				, QUOTENAME(schema_name(objectproperty(c.conflict_tableid, 'SchemaId')) ) + '.' + QUOTENAME(OBJECT_NAME(c.conflict_tableid))
			from (syspublications as a join sysarticles as b on a.pubid = b.pubid)
				join sysarticleupdates as c on c.artid = b.artid and c.pubid = b.pubid
			where a.allow_queued_tran = 1 and a.conflict_retention>0

		open hCftTab
		fetch hCftTab into @tranpubid, @conflict_retention, @conflict_table
		while (@@fetch_status != -1)
		begin
			
			-- delete the expired messages
			
			select @cmd = N'delete ' + @conflict_table +
				N' where datediff(dd, insertdate, getdate()) > ' +
				cast(@conflict_retention as nvarchar(10)) +
				N' and pubid = ' + cast(@tranpubid as nvarchar(10))

			execute (@cmd)
			if (@@error != 0)
			begin
				close hCftTab
				deallocate hCftTab
				return 1
			end
				
			
			-- Get next conflict table to clean
			
			fetch hCftTab into @tranpubid, @conflict_retention, @conflict_table
		end

		
		-- close cursor
		
		close hCftTab
		deallocate hCftTab
	end

	
	-- all done
	
	return 0
END

 
Last revision 2008RTM
See also

  sp_MSdrop_expired_mergesubscription (Procedure)
sp_MSdrop_expired_subscription (Procedure)
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