Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MScreatelightweightarticleprocs

  No additional text.


Syntax
create procedure sys.sp_MScreatelightweightarticleprocs
	@pubid		uniqueidentifier,
	@artid		uniqueidentifier,
	@conflict_proc sysname = NULL
as
	set nocount on

	declare @tablenick			int
	declare @destination_object	sysname
	declare @procname			nvarchar(70)
	declare @cmd				nvarchar(4000)
	declare @qualified_name 	nvarchar(517)
	declare @postfix			nchar(32)
    declare @retcode			smallint
    declare @dbname				sysname
    declare @destination_owner	sysname
    declare @updateable		bit
    declare @conflict_table sysname
    declare @objid			int
    declare @conflict_table_schema sysname

	select @tablenick= nickname, @destination_object= destination_object,
		   @postfix= procname_postfix, @destination_owner= destination_owner,
		   @conflict_table = conflict_table, @objid = objid
		from dbo.sysmergearticles
		where pubid = @pubid and artid = @artid

	set @updateable= sys.fn_MSarticle_allows_DML_at_this_replica(@artid, default)
	set @dbname= db_name()

	if @destination_owner is NULL or @destination_owner=''
		select @qualified_name = quotename(@destination_object)
	else
		select @qualified_name = quotename(@destination_owner) + '.' + quotename(@destination_object)

	-- Create multipurpose proc.
	set @procname= 'MSmerge_lws_sp_multi_' + @postfix
	if not exists (select * from sys.procedures where name = @procname and type = 'P')
	begin
		set @cmd= 'sys.sp_MScreatelightweightmultipurposeproc
					@pubid= [' + convert(nchar(36), @pubid) + '],
					@artid= [' + convert(nchar(36), @artid) + ']'
        exec @retcode= sys.xp_execresultset @cmd, @dbname
        if @@error <> 0 or @retcode <> 0 return 1
        set @cmd= 'grant exec on ' + quotename(@procname) + ' to public'
		exec @retcode= sys.sp_executesql @cmd
        if @@error <> 0 or @retcode <> 0 return 1
	end

	-- Create insert proc.
	set @procname= 'MSmerge_lws_sp_ins_' + @postfix
	if not exists (select * from sys.procedures where name = @procname and type = 'P')
	begin
		set @cmd= 'sys.sp_MScreatelightweightinsertproc
					@pubid= [' + convert(nchar(36), @pubid) + '],
					@artid= [' + convert(nchar(36), @artid) + ']'
        exec @retcode= sys.xp_execresultset @cmd, @dbname
        if @@error <> 0 or @retcode <> 0 return 1
        set @cmd= 'grant exec on ' + quotename(@procname) + ' to public'
		exec @retcode= sys.sp_executesql @cmd
        if @@error <> 0 or @retcode <> 0 return 1
	end

	-- Create update proc.
	set @procname= 'MSmerge_lws_sp_upd_' + @postfix
	if not exists (select * from sys.procedures where name = @procname and type = 'P')
	begin
		set @cmd= 'sys.sp_MScreatelightweightupdateproc
					@pubid= [' + convert(nchar(36), @pubid) + '],
					@artid= [' + convert(nchar(36), @artid) + ']'
        exec @retcode= sys.xp_execresultset @cmd, @dbname
        if @@error <> 0 or @retcode <> 0 return 1
        set @cmd= 'grant exec on ' + quotename(@procname) + ' to public'
		exec @retcode= sys.sp_executesql @cmd
        if @@error <> 0 or @retcode <> 0 return 1
	end
	
	-- Create delete proc.
	set @procname= 'MSmerge_lws_sp_del_' + @postfix
	if not exists (select * from sys.procedures where name = @procname and type = 'P')
	begin
		exec @retcode= sys.sp_MScreatelightweightdeleteproc
						@procname= @procname,
						@destination_object= @qualified_name,
						@tablenick= @tablenick
        if @@error <> 0 or @retcode <> 0 return 1
	end


    if @conflict_proc IS NOT NULL
    begin
        select @conflict_table_schema = SCHEMA_NAME(schema_id) from sys.objects where name = @conflict_table and type = 'U'
        if @@ERROR<>0  return 1

        set @cmd = 'sys.sp_MSmakeconflictinsertproc ' + QUOTENAME(@conflict_table) + ' , ' + QUOTENAME(@conflict_table_schema) + ' , ' + quotename(@conflict_proc)  + ' , ' + convert(nvarchar,@objid)
        set @cmd = @cmd + ', [' + convert(nchar(36), @pubid) + ']'
        exec @retcode = sys.xp_execresultset @cmd, @dbname
        if @@ERROR<>0 OR @retcode<>0  return 1
        exec @retcode = sys.sp_MS_marksystemobject @conflict_proc
        if @@ERROR<>0 or @retcode<>0  return 1
		set @cmd = 'grant exec on ' + quotename(@conflict_proc) + ' to public'
        exec @retcode = sys.sp_executesql @cmd
        if @@ERROR<>0 or @retcode<>0 return 1
        update dbo.sysmergearticles set ins_conflict_proc = @conflict_proc where artid = @artid and pubid=@pubid
    end

	return 0

 
Last revision 2008RTM
See also

  sp_MScreatelightweightprocstriggersconstraints (Procedure)
sp_MSmakearticleprocs (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