Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSscript_insert_subwins

  No additional text.


Syntax
create procedure sys.sp_MSscript_insert_subwins
(
	@publication sysname		-- publication name
	,@article sysname			-- article name
	,@objid int				-- object id
	,@artid int				-- article id
	,@identity_insert bit		-- enable identity insert
)
as
begin
	declare @cmd nvarchar(4000)
			,@qualname nvarchar(517)
			,@rc           int
			,@fhasnonpkuniquekeys int

	exec sp_MSget_qualified_name @objid, @qualname OUTPUT
	
	--  check if this article has non PK unique keys
	
	exec @fhasnonpkuniquekeys = sp_repltablehasnonpkuniquekey @tabid = @objid
	
	-- start scripting
	
	select @cmd = N'
	if (@execution_mode = @QSubWins)
	begin
		'+N'
		'+N'-- Subscriber wins resolution
		'+N'-- '
	insert into #proctext(procedure_text) values( @cmd )
	
	-- script this block if the article has non PK unique keys
	
	if (@fhasnonpkuniquekeys = 1)
	begin
		select @cmd = N'
		if (@cftcase = 22)
		begin
			'+N'
			'+N'-- delete rows with values of non PK keys
			'+N'-- '
		insert into #proctext(procedure_text) values( @cmd )
		
		-- script delete rows with values for non PK keys
		
		select @cmd = N'
			delete ' + @qualname
		insert into #proctext(procedure_text) values( @cmd )
		exec @rc = sp_replscriptuniquekeywhereclause @tabid = @objid
					,@artid = @artid
					,@prefix = N'@c'
					,@suffix = NULL
					,@mode = 7
		
		-- continue scripting
		
		select @cmd = N'
		end'
		insert into #proctext(procedure_text) values( @cmd )
	end
	
	-- continue scripting
	
	select @cmd = N'
		if (@cftcase = 21)
		begin
			'+N'
			'+N'-- delete rows with values of all keys
			'+N'-- '
	insert into #proctext(procedure_text) values( @cmd )
	
	-- script delete rows with values of all keys
	
	select @cmd = N'
			delete ' + @qualname
	insert into #proctext(procedure_text) values( @cmd )
	exec @rc = sp_replscriptuniquekeywhereclause @tabid = @objid
				,@artid = @artid
				,@prefix = N'@c'
				,@suffix = NULL
				,@mode = 6
	
	-- continue scripting
	
	select @cmd = N'
		end
		if (@cftcase in (21,22))
		begin
			'+N'
			'+N'-- insert row
			'+N'-- '
	insert into #proctext(procedure_text) values( @cmd )
	
	-- script insert row
	
	exec @rc = sp_script_insertforcftresolution
			@objid = @objid
			,@artid = @artid
			,@identity_insert = @identity_insert
			,@prefix = N'@c'
			,@suffix = NULL
	
	-- continue scripting
	
	select @cmd = N'
		end

		'+N'
		'+N'-- 
		'+N'-- all done for conflict resolution for Subscriber Wins policy
		'+N'-- 
		'+N'
	end'
	insert into #proctext(procedure_text) values( @cmd )
	
	-- all done
	
	return 0
end

 
Last revision 2008RTM
See also

  sp_MSdrop_repltran (Procedure)
sp_MSscript_sync_ins_proc (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