Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_cdc_cleanup_change_table

  No additional text.


Syntax
create procedure [sys].[sp_cdc_cleanup_change_table]
(
	@capture_instance sysname,
	@low_water_mark	binary(10),
	@threshold bigint = 5000
)
as
begin
	declare @retcode int
			,@db_name sysname
			,@xstr1 nvarchar(22)
	
    set nocount on

    set @db_name = db_name()

    -- Verify caller is authorized to clean up change tracking
    if (isnull(is_srvrolemember('sysadmin'),0) = 0) and (isnull(is_member('db_owner'),0) = 0)
    begin
   		raiserror(22904, 16, -1)
        return 1
    end

    -- Verify database is enabled for change tracking
    if ([sys].[fn_cdc_is_db_enabled]() != 1)
    begin
		raiserror(22910, 16, -1, @db_name)
        return 1
    end

    -- Parameter @threshold must be positive
    if (@threshold <= 0)
    begin
  		raiserror(22850, 16, -1)
        return 1
    end

    -- If non-null, parameter @low_water_mark must appear as the start_lsn
    -- value of a current entry in the cdc.lsn_time_mapping table.
    if (@low_water_mark is not null)
    begin
		if not exists
			( select start_lsn from cdc.lsn_time_mapping
			where start_lsn = @low_water_mark )
		begin
			set @xstr1 = upper(sys.fn_varbintohexstr(@low_water_mark))
			raiserror(22964, 16, -1, @xstr1)
			return 1
		end
	end		

	-- Call internal stored procedure to do the work
	-- Switch to database 'cdc' user to mitigate against malicious dbo triggers
	execute as user = 'cdc'
	
    exec @retcode = sys.sp_cdc_cleanup_change_table_internal
    	@capture_instance,
		@low_water_mark,
		@threshold
		
	if (@@error <> 0) or (@retcode <> 0)
	begin
		revert
        return 1
	end
	
	revert
	
	return 0		
end

 
Last revision 2008RTM
See also

  sp_cdc_cleanup_change_tables (Procedure)
sp_cdc_cleanup_change_table_internal (Procedure)
sp_cdc_cleanup_job_internal (Procedure)
sp_MSdrop_cdc (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