Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSdroparticleprocs

  No additional text.


Syntax
create procedure sys.sp_MSdroparticleprocs
    (@pubid uniqueidentifier, @artid uniqueidentifier, @update_proc_names bit = 1)
as
    set nocount on
    declare @ins_procname     sysname
    declare @upd_procname     sysname
    declare @sel_procname    sysname
    declare @metadata_select_procname    sysname
    declare @del_procname    sysname
    declare @ins_batch_procname sysname
    declare @upd_batch_procname sysname
    declare @tmp_procname    nvarchar(300)
    declare @view_sel_proc     nvarchar(290)
    declare @owner            sysname
    declare @objid            int
    declare @retcode        tinyint
    declare @backward_comp_level int
    declare @art_proc_suffix nvarchar(40)

    -- get the insert, update and conflict proc names from dbo.sysmergearticles

    exec @art_proc_suffix = sys.fn_MSmerge_getartprocsuffix @artid, @pubid

    select @ins_procname = 'MSmerge_ins_sp_' + @art_proc_suffix
    select @upd_procname = 'MSmerge_upd_sp_' + @art_proc_suffix
    select @sel_procname = 'MSmerge_sel_sp_' + @art_proc_suffix
    select @view_sel_proc = 'MSmerge_sel_' + @art_proc_suffix
    select @metadata_select_procname = 'MSmerge_sel_sp_' + @art_proc_suffix + '_metadata'
    select @del_procname = 'MSmerge_del_sp_' + @art_proc_suffix
    select @ins_batch_procname = @ins_procname + '_batch'
    select @upd_batch_procname = @upd_procname + '_batch'

    if (@ins_procname IS NOT NULL) and exists (select * from sys.objects where
            name = @ins_procname and type = 'P')
    begin
        select @owner = schema_name(schema_id) from sys.objects where name=@ins_procname
        select @tmp_procname = QUOTENAME(@owner) + '.' + QUOTENAME(@ins_procname)
        exec ('drop proc ' + @tmp_procname)
        if @@ERROR<>0 return (1)
    end

    if (@ins_batch_procname IS NOT NULL) and exists (select * from sys.objects where
            name = @ins_batch_procname and type = 'P')
    begin
        select @owner = schema_name(schema_id) from sys.objects where name=@ins_batch_procname
        select @tmp_procname = QUOTENAME(@owner) + '.' + QUOTENAME(@ins_batch_procname)
        exec ('drop proc ' + @tmp_procname)
        if @@ERROR<>0 return (1)
    end

    if (@upd_procname IS NOT NULL) and exists (select * from sys.objects where
            name = @upd_procname and type = 'P')
    begin
        select @owner = schema_name(schema_id) from sys.objects where name=@upd_procname
        select @tmp_procname = QUOTENAME(@owner) + '.' + QUOTENAME(@upd_procname)
        exec ('drop proc ' + @tmp_procname)
        if @@ERROR<>0 return (1)
    end

    if (@upd_batch_procname IS NOT NULL) and exists (select * from sys.objects where
            name = @upd_batch_procname and type = 'P')
    begin
        select @owner = schema_name(schema_id) from sys.objects where name=@upd_batch_procname
        select @tmp_procname = QUOTENAME(@owner) + '.' + QUOTENAME(@upd_batch_procname)
        exec ('drop proc ' + @tmp_procname)
        if @@ERROR<>0 return (1)
    end

    if (@sel_procname IS NOT NULL) and exists (select * from sys.objects where
            name = @sel_procname and type = 'P')
    begin
        select @owner = schema_name(schema_id) from sys.objects where name=@sel_procname
        select @tmp_procname = QUOTENAME(@owner) + '.' + QUOTENAME(@sel_procname)
        exec ('drop proc ' + @tmp_procname)
        if @@ERROR<>0 return (1)
    end

    if (@metadata_select_procname IS NOT NULL) and exists (select * from sys.objects where
            name = @metadata_select_procname and type = 'P')
    begin
        select @owner = schema_name(schema_id) from sys.objects where name=@metadata_select_procname
        select @tmp_procname = QUOTENAME(@owner) + '.' + QUOTENAME(@metadata_select_procname)
        exec ('drop proc ' + @tmp_procname)
        if @@ERROR<>0 return (1)
    end

    if (@del_procname IS NOT NULL) and exists (select * from sys.objects where
            name = @del_procname and type = 'P')
    begin
        select @owner = schema_name(schema_id) from sys.objects where name=@del_procname
        select @tmp_procname = QUOTENAME(@owner) + '.' + QUOTENAME(@del_procname)
        exec ('drop proc ' + @tmp_procname)
        if @@ERROR<>0 return (1)
    end

    if (@view_sel_proc IS NOT NULL) and exists (select * from sys.objects where
            name = @view_sel_proc and type = 'P')
    begin
        select @owner = schema_name(schema_id) from sys.objects where name=@view_sel_proc
        select @tmp_procname = QUOTENAME(@owner) + '.' + QUOTENAME(@view_sel_proc)
        exec ('drop proc ' + @tmp_procname)
        if @@ERROR<>0 return (1)
    end

    -- The reason a backward_comp_level check is done here is because the 7.0 merge agent calls sp_MSgetconflictinsertproc
    -- without a pubid. Hence the same proc would be used if two publications shared an article. If our backward_comp_level
    -- allows 70 it is possible and we have this table published in another publication then we should not delete the
    -- conflict insert proc
    select @backward_comp_level = backward_comp_level from dbo.sysmergepublications where pubid = @pubid

    if (@backward_comp_level >= 40) or not exists (select * from dbo.sysmergearticles where artid=@artid and pubid<>@pubid)
    begin
        exec @retcode= sys.sp_MSdrop_ins_conflict_proc @pubid=@pubid, @artid=@artid, @update_proc_names = @update_proc_names
        if @@error<>0 or @retcode<>0 return 1
    end

    -- drop down level procs always. There is no harm in doing this since we are dropping all procs anyway.
    -- this will help cleanup in some cases where after upgrade or after switching to 90 compat level the old
    -- downlevel procs are left behind
    exec @retcode = sys.sp_MSmerge_dropdownlevelprocs @artid, @pubid
    if @retcode<>0 or @@error<>0
        return 1

    if @update_proc_names = 1
    begin
        update dbo.sysmergearticles set insert_proc = NULL,
                                        update_proc = NULL,
                                        select_proc = NULL,
                                        metadata_select_proc = NULL,
                                        delete_proc = NULL,
                                        view_sel_proc = NULL
                where pubid=@pubid and artid=@artid
    end

    return 0

 
Last revision 2008RTM
See also

  sp_MSarticlecleanup (Procedure)
sp_MSdropmergearticle (Procedure)
sp_MSsetartprocs (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