Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSsetfilteredstatus

  No additional text.


Syntax
create procedure sys.sp_MSsetfilteredstatus @object_id int
as
    declare @qualified_name nvarchar(517)
    		,@retcode int
    		,@setFlag bit
		,@pkkey sysname
		,@source_table sysname
		,@fcdc_tracked bit
		
    exec @retcode = sys.sp_MSreplcheck_publish
    if @@ERROR <> 0 or @retcode <> 0
        return(1)

    exec sys.sp_MSget_qualified_name @object_id, @qualified_name output

    BEGIN TRANSACTION
	declare @cdc_tracked_tables table (object_id int)
	
	if object_id('cdc.change_tables') is not null
	begin
		insert @cdc_tracked_tables select distinct source_object_id from cdc.change_tables
	end
	if (@@rowcount = 0)
		set @fcdc_tracked = 0
	else
		set @fcdc_tracked = 1

    if not (@qualified_name is null)
    begin
        EXEC %%Object(MultiName = @qualified_name).LockMatchID(ID = @object_id, Exclusive = 1, BindInternal = 0)
        if @@error <> 0
            select @qualified_name = null
    end

    if @qualified_name is null
    begin
        raiserror(18750, -1, -1, 'sp_MSsetfilteredstatus', 'object_id');
        goto error_abort_exit
    end

    if exists( select * from sys.objects where type = 'RF' and parent_object_id = @object_id )
      or exists( select * from sysarticles A join syspublications P on A.pubid = P.pubid where A.objid = @object_id and (P.allow_queued_tran = 1 or P.allow_sync_tran = 1))
      or exists( select * from sysarticles where objid = @object_id and (upper(upd_cmd) like 'CALL%' OR upper(upd_cmd) like 'XCALL%' ) )
      or exists( select * from sysarticles where objid = @object_id and (upper(del_cmd) like 'XCALL%' ) )
      or exists( select * from sysarticles sa, syssubscriptions ss where sa.objid = @object_id and sa.artid = ss.artid and ss.status = 3)
    begin
        EXEC %%Relation(ID = @object_id).SetHasFilterProc(Value = 1)
    	set @setFlag = 1
    end
    else
    begin
		if (@fcdc_tracked = 0)
	       EXEC %%Relation(ID = @object_id).SetHasFilterProc(Value = 0)
    	set @setFlag = 0
    end

	--set/reset IsLoggedForRepl for all replicated column (except legacy blobs) depand on if has_replication_filter is set
	--this controls logging behavior of offrow columns in deletes

	--don't clear the bits if table is still being tracked by cdc
	if(@setFlag = 1 or @fcdc_tracked = 0)
	begin
		declare #hpk cursor local fast_forward for
			select name from sys.columns where object_id = @object_id and is_replicated = 1
					and system_type_id not in (34, 35, 99) --image, text. ntext
					and user_type_id not in  (34, 35, 99) --image, text. ntext
		open #hpk
		fetch #hpk into @pkkey
		while (@@fetch_status = 0)
		begin
			EXEC %%ColumnEx(ObjectID = @object_id, Name = @pkkey).SetLogForRepl(Value = @setFlag)
			IF @@ERROR <> 0
			BEGIN
				select @source_table = object_name(@object_id)
				RAISERROR(15052, -1, -1, @source_table)
				return 1
			END
			fetch #hpk into @pkkey
		end
		close #hpk
		deallocate #hpk

		--in case of turning of has_replicate_filter, make sure IsLoggedForRepl is still set for base of pk/computed pk columns
		if(@setFlag = 0)
		begin
			exec @retcode = sp_MSSetLogForRepl @object_id
		    if @@ERROR <> 0 or @retcode <> 0
		        return(1)
		end
	end
    COMMIT TRANSACTION
    return (0)

error_abort_exit:
    IF @@TRANCOUNT = 1
        ROLLBACK TRAN
    ELSE COMMIT TRAN
    return (1)

 
Last revision 2008RTM
See also

  sp_MSarticlecol (Procedure)
sp_MSdrop_repltran (Procedure)
sp_MSrepl_articlefilter (Procedure)
sp_MSrepl_changearticle (Procedure)
sp_MSrepl_changesubstatus (Procedure)
sp_MSrepl_droparticle (Procedure)
sp_vupgrade_updatingpublicationarticle (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