Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MScdc_tranrepl_check

  No additional text.


Syntax
create procedure sys.sp_MScdc_tranrepl_check
@logreader_exists bit  = 0 output
,@skip_remote_check bit = 0
as
begin
	
	-- If transactional replication is enabled on this db and there is an active publication (logreader agent exists)
	-- return an error to indicate the capture job should not be run.
	
	if exists (select * from sys.databases where database_id = db_id() and is_published = 1)
	begin
		--syspublications should exists if db is published, but validate it anyway just to be safe
		if object_id('syspublications') is not null
		begin
			--there's at least active tran publication
			if exists (select * from syspublications where status = 1 and repl_freq = 0)
			begin
				set @logreader_exists = 1
				if(@skip_remote_check = 0)
				begin
					RAISERROR(22911, 16, -1)
					return (1)
				end
				return (0)
			end
			if(@skip_remote_check = 1)
				return (0)
			--if there's no active tran publication, let's make sure there isn't a logreader being manually added by user.
			declare @retcode INT
						,@distributor sysname
						,@distribdb sysname
						,@publisher sysname
						,@publisher_db sysname
						,@distproc nvarchar(1000)
			select @publisher = publishingservername()
					,@publisher_db = db_name()
			EXEC @retcode = sys.sp_MSrepl_getdistributorinfo @publisher = @publisher,
			                                                                @rpcsrvname = @distributor OUTPUT,
			                                                                @distribdb = @distribdb OUTPUT
			--can not let this go silently, user may shut down distributor, and add cdc job otherwise			
			IF @@error <> 0 OR @retcode <> 0 or @distribdb IS NULL OR @distributor IS NULL
			BEGIN
				RAISERROR (22804, 16, -1)
				RETURN (1)
			END
			SELECT @distproc =  QUOTENAME(RTRIM(@distributor)) + N'.' + QUOTENAME(@distribdb) + N'.sys.sp_MSreplagentjobexists'
			EXEC @retcode = @distproc @exists = @logreader_exists output,
			                            @type = 2,
			                            @publisher = @publisher,
			                            @publisher_db = @publisher_db
			IF @@ERROR <> 0 or @retcode <> 0
			BEGIN
					RAISERROR (22804, 16, -1)
					RETURN (1)
			END
			if(@logreader_exists = 1)
			begin
				if(@skip_remote_check = 0)
				begin
					RAISERROR(22911, 16, -1)
					return (1)
				end
				return (0)
			end
		end				
	end

    return(0)
end

 
Last revision 2008RTM
See also

  sp_cdc_add_job (Procedure)
sp_cdc_scan (Procedure)
sp_cdc_start_job (Procedure)
sp_MScdc_capture_job (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