Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSinsertschemachange

  No additional text.


Syntax

create procedure sys.sp_MSinsertschemachange(
    @pubid          uniqueidentifier,
    @artid          uniqueidentifier = NULL, /* Can be NULL for directory commands */
    @schemaversion  int,
    @schemaguid     uniqueidentifier,
    @schematype     int,
    @schematext     nvarchar(max),
    @schemasubtype      int = 0,
    @update_schemaversion tinyint = 1
    )
as
    declare @retcode            int
    declare @constraintname     sysname
    declare @owner              sysname
    declare @tablename          sysname
    declare @qualname           nvarchar(270)
    declare @objid              int
    declare @alter_table_type   int
    declare @subid    uniqueidentifier

    /*
    ** Check for subscribing permission
    */
    exec @retcode=sys.sp_MSreplcheck_subscribe
    if @retcode<>0 or @@ERROR<>0 return (1)

    select @alter_table_type = 11

    /* Parameter validation */
    if (@schemaversion is null)
        begin
        RAISERROR(14043, 16, -1, '@schemaversion', 'sp_MSinsertschemachange')
        return (1)
        end

    /*
    ** Special case: for push subscription, reinit-with-upload, we do not want to cleanup subscriber side
    ** cause we need to upload; however we still need to apply alter-table. To avoid duplicate key insert
    ** failure, we no-OP this insert of alter-table schema.
    */
    if @schematype=@alter_table_type and exists
        (select * from dbo.sysmergeschemachange where pubid=@pubid and schemaversion=@schemaversion)
        return (1)

    begin transaction tran_sp_MSinsertschemachange
	save transaction tran_sp_MSinsertschemachange

    if not exists (select * from dbo.sysmergeschemachange with (HOLDLOCK TABLOCKX)
                where pubid=@pubid and artid=@artid and
                      schemaversion=@schemaversion and schemaguid = @schemaguid and
                      schematype = @schematype)
    begin
        insert into dbo.sysmergeschemachange with (HOLDLOCK TABLOCKX)
        (pubid, artid, schemaversion, schemaguid, schematype, schematext, schemasubtype)
                 values (@pubid, @artid, @schemaversion, @schemaguid, @schematype, @schematext, @schemasubtype)
    end
    else
    begin
        update dbo.sysmergeschemachange with (HOLDLOCK TABLOCKX)
        	set schematext = @schematext
        	where pubid=@pubid and artid=@artid and
                      schemaversion=@schemaversion and schemaguid = @schemaguid and
                      schematype = @schematype
    end
    if @@error <> 0
    begin
        rollback transaction tran_sp_MSinsertschemachange
	    commit transaction
        RAISERROR(21305 , 16, -1)
        return (1)
    end

    /* update the schema version and schemaguid in dbo.sysmergesubscriptions - The following servername is used as a publishing server name */
    if @update_schemaversion = 1
    begin
        select @subid = subid from dbo.sysmergesubscriptions
            where UPPER(subscriber_server) collate database_default = UPPER(publishingservername()) collate database_default
               and db_name = DB_NAME() and pubid = @pubid

        update dbo.sysmergesubscriptions set schemaversion = @schemaversion, schemaguid = @schemaguid
            where subid = @subid and (schemaversion<@schemaversion or schemaversion is NULL)
        if @@error <> 0
            begin
            rollback transaction tran_sp_MSinsertschemachange
    	    commit transaction
            RAISERROR(21305 , 16, -1)
            return (1)
        end
    end
    commit transaction
    return (0)

 
Last revision 2008RTM
See also

  sp_changemergearticle (Procedure)
sp_changemergepublication (Procedure)
sp_changemergepullsubscription (Procedure)
sp_changemergesubscription (Procedure)
sp_dropmergearticle (Procedure)
sp_MSadd_mergereplcommand (Procedure)
sp_MSchange_mergearticle (Procedure)
sp_MSchange_retention (Procedure)
sp_MSchange_retention_period_unit (Procedure)
sp_MSdrop_rlrecon (Procedure)
sp_MSinsertgenerationschemachanges (Procedure)
sp_MSmerge_altertable (Procedure)
sp_MSmerge_passDDLcmd (Procedure)
sp_MSNonSQLDDL (Procedure)
sp_MSpropagateschematorepubs (Procedure)
sp_MSreinitmergepublication (Procedure)
sp_MSreinit_hub (Procedure)
sp_MSremoveidrangesupport (Procedure)
sp_MSrepl_addscriptexec (Procedure)
sp_MSupsertschemachange (Procedure)
sp_repladdcolumn (Procedure)
sp_repldropcolumn (Procedure)
sp_validatemergepublication (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