Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSscript_update_subwins

  No additional text.


Syntax
create procedure sys.sp_MSscript_update_subwins
(
	@publication sysname		-- publication name
	,@article sysname			-- article name
	,@objid int				-- object id
	,@artid int				-- article id
	,@identity_insert bit
)
AS
BEGIN
	declare @cmd nvarchar(4000)
			,@pubid int
			,@qualname nvarchar(517)
			,@rc           int
			,@fhasnonpkuniquekeys int

	
	-- initialize the vars we will use
	
	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'
		if (@cftcase in (10,11,14,15,18,20,21,22))
		begin
			'+N'
			'+N'-- delete the row with OLD_PK
			'+N'--'
	insert into #proctext(procedure_text) values( @cmd )
	
	-- script delete with PK=OLD_PK
	
	select @cmd = N'
			delete ' + @qualname
	insert into #proctext(procedure_text) values( @cmd )
	exec sp_MSscript_where_clause @objid, @artid, 'upd version', NULL, 0
	
	-- continue scripting
	
	select @cmd = N'
		end'
	insert into #proctext(procedure_text) values( @cmd )
	
	-- if the table has non PK unique keys
	-- generate the commands for non PK keys
	
	if (@fhasnonpkuniquekeys = 1)
	begin
		select @cmd = N'
		if (@cftcase in (17,20,22,23))
		begin
			'+N'
			'+N'-- delete with NEW values of non PK keys
			'+N'--'
		insert into #proctext(procedure_text) values( @cmd )
		
		-- script delete with NEW values of 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 in (15,16))
		begin
			'+N'
			'+N'-- delete with NEW values of all keys
			'+N'--'
	insert into #proctext(procedure_text) values( @cmd )
	
	-- script delete with NEW 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 (10,11,12,13,14,15,16,17,18,20,21,22,23,24))
		begin
			'+N'
			'+N'-- insert with NEW values of all keys
			'+N'--'
	insert into #proctext(procedure_text) values( @cmd )
	
	
	-- generate insert statement with NEW values
	
	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_upd_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