Home Microsoft SQL Server DigiMailing iRN Contact


  No additional text.

create procedure sys.sp_MSscript_delete_pubwins
	@publication sysname		-- publication name
	,@article sysname			-- article name
	,@objid int				-- object id
	declare @cmd nvarchar(4000)
			,@artid int
			,@pubid int
			,@dest_table sysname
			,@dest_owner nvarchar(260)
			,@rc           int
			,@qualname nvarchar(517)
			,@fhasnonpkuniquekeys int

	-- initialize the vars we will use
	select @pubid = pubid from syspublications where name = @publication
	select @artid = artid, @dest_table = dest_table, @dest_owner = dest_owner
	from sysarticles where name = @article and pubid = @pubid
	select @dest_owner = case when (@dest_owner IS NULL) then N''
				else quotename(@dest_owner) + N'.' end
	exec sp_MSget_qualified_name @objid, @qualname OUTPUT
	-- start scripting
	select @cmd = N'
	if (@execution_mode = @QPubWins)
		'+N'-- Publisher wins resolution
		'+N'-- '
	insert into #proctext(procedure_text) values( @cmd )
	-- declare fetch variables for cursor
	exec @rc = sp_scriptpubwinsrefreshcursorvars @objid
	-- continue scripting
	select @cmd = N'

		'+N'-- Perform refresh(delete+insert) generations next
		'+N'-- Generate delete+insert for values of all keys
		if (@cftcase in (30,31))
	insert into #proctext(procedure_text) values( @cmd )
	-- generate delete compensating command for OLD values of all unique keys
	select @cmd = N'
			select @cmd = N''DELETE ' + sys.fn_replreplacesinglequote(@dest_owner) collate database_default
		+ sys.fn_replreplacesinglequote(quotename(@dest_table)) collate database_default + N' '' + '
	insert into #proctext(procedure_text) values( @cmd )
	exec @rc = sp_replscriptuniquekeywhereclause @tabid = @objid
				,@artid = @artid
				,@prefix = N'@c'
				,@suffix = N'_old'
				,@mode = 4
	-- script the sending command
	exec sp_MSscript_compensating_send @pubid, @artid, 0, 1
	-- script the refresh commands for OLD values of all unique keys
	exec @rc = sp_MSscript_compensating_insert @publication, @article, @objid, 4, 0
	if (@rc != 0 or @@error != 0)
		return 1
	-- continue scripting
	select @cmd = N'
		'+N'-- all done for conflict resolution for Publisher Wins policy
	insert into #proctext(procedure_text) values( @cmd )
	-- all done
	return 0		

Last revision 2008RTM
See also

  sp_MSdrop_repltran (Procedure)
sp_MSscript_sync_del_proc (Procedure)


  Query a named instance
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
Zoekmachine optimalisatie
SQL Servers hidden objects
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
sIFR; de combinatie tussen HTML en Flash