Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSscript_sync_ins_proc

  No additional text.


Syntax
create procedure sys.sp_MSscript_sync_ins_proc (
    @publication sysname,
    @article     sysname,
    @procname    sysname,
    @alter bit = 0 -- if 1 script alter, otherwise script create
)
as
BEGIN
    declare @source_objid int
            ,@colname sysname
            ,@artid int
            ,@indid int
            ,@cmd          nvarchar(4000)
            ,@outvars      nvarchar(4000)
            ,@rc           int
            ,@error_cmd tinyint
            ,@identity_insert bit
            ,@queued_pub bit

    set nocount on
    
    -- security check -- dbo+ to script create or script alter
    
    exec @rc = sys.sp_MSreplcheck_publish
    if @@error <> 0 or @rc <> 0
    begin
        return (1)
    end

    
    -- Create temp table
    
    create table #proctext ( c1 int identity NOT NULL, procedure_text nvarchar(4000) collate database_default null)
    select @queued_pub = allow_queued_tran from syspublications where name = @publication
    
    -- proc definition
    
    exec @rc = sys.sp_MSscript_beginproc @publication, @article, @procname, @source_objid output, @artid output, @alter
    if @@error <> 0 or @rc <> 0
        return
    
    -- Check to see if identity insert must be turned on
    -- i.e. Does the table has identity that are included in the partition?
    
    exec sys.sp_MSis_identity_insert @publication = @publication
            ,@article = @article
            ,@identity_insert = @identity_insert output
            ,@mode = 1
    
    -- construct parameter list
    
    exec sys.sp_MSscript_params @source_objid, @artid, null, 1,  @outvars output
    
    -- add other parameters and start body of proc
    
    exec sys.sp_MSscript_procbodystart @queued_pub, @identity_insert
    
    -- script the security and execution mode  and subscription validation checks
    
    exec sys.sp_MSscript_ExecutionMode_stmt @publication, @article, 0
    
    -- Work around for case where article has 1 col that is not user-modfied (identity, timestamp)
    -- *** Do we need to check this here 
    -- *** we should be checking this when creating subscription
    
    exec @rc = sys.sp_MStable_not_modifiable @source_objid, @artid
    if @rc = 1
        select @error_cmd = 1
    else
    begin
        exec @indid = sys.sp_MStable_has_unique_index @source_objid
        if (@outvars is not null and @indid = 0)
            -- no insert/update allowed if timestamp/identity col and no unique index
            select @error_cmd = 1
        else
            select @error_cmd = 0
    end

    if (@error_cmd = 0)
    begin
        
        -- script insert statemnt
        
        exec sys.sp_MSscript_insert_statement @source_objid, @artid, @identity_insert, @queued_pub
        
        -- script queued specific stuff
        
        if (@queued_pub = 1)
        begin
            
            -- script Conflict finder
            
            exec sp_MSscriptinsertconflictfinder @publication, @article, @source_objid
            
            -- script Conflict resolution block for Publisher Wins case
            
            exec sys.sp_MSscript_insert_pubwins @publication, @article, @source_objid
            
            -- script Conflict resolution block for Subscriber Wins case
            
            exec sys.sp_MSscript_insert_subwins @publication, @article, @source_objid, @artid, @identity_insert
        end
        
        -- script closing
        
        exec sys.sp_MSscript_endproc @source_objid, 'ins', @artid, @outvars, @queued_pub, @identity_insert
    end
    else
    begin
        
        -- Generate error command and finish
        
        insert into #proctext(procedure_text) values( N'
    exec sys.sp_MSreplraiserror 20516
END
')
    end
    
    -- send fragments to client
    
    select procedure_text from #proctext order by c1 asc
END

 
Last revision 2008RTM
See also

  sp_MSdrop_repltran (Procedure)
sp_MSgen_sync_tran_procs (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