Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSdodatabasesnapshotinitiation

  No additional text.


Syntax

-- Name: sp_MSdodatabasesnapshotinitiation

-- Description: This procedure is called by the snapshot agent to perform the
--              the necessary (article & subscription) initiation procedures
--              when generating a snapshot from a database snapshot.
-- Parameter: @publication sysname (mandatory)

-- Notes: This procedure is assumed to be run within a transaction from the
--        snapshot agent. As such, no explicit error handling is performed
--        in it. This procedure will also return 1 immediately if one of the
--        following is not true:
--        1) Caller is not member of db_owner role
--        2) Caller is not a replication agent connection
--        3) @@trancount < 1

-- Returns: 0 - succeeded
--          1 - failed

-- Security: Public interface, non-db_owner caller will result in no-op

create procedure sys.sp_MSdodatabasesnapshotinitiation (
    @publication sysname
    )
as
begin
    set nocount on

    if @@trancount < 1 return 1

    if sessionproperty('replication_agent') <> 1 return 1

    if object_id(N'dbo.syspublications', 'U') is null return 1

    declare @retcode int
    set @retcode = 0

    exec @retcode = sys.sp_MSreplcheck_publish
    if @@error <> 0 or @retcode <> 0
        return 1

    declare @qualifiedname nvarchar(520),
            @objid int,
            @articletype tinyint,
            @pubid int,
            @repl_freq tinyint,
            @error int

    set @pubid = null
    set @error = 0

    select @pubid = pubid,
           @repl_freq = repl_freq
      from dbo.syspublications
     where name = @publication

    if @pubid is null return 1

        update dbo.syssubscriptions
           set status = 3
          from dbo.syssubscriptions subs
    inner join dbo.sysextendedarticlesview arts
            on subs.artid = arts.artid
         where arts.pubid = @pubid
           and (subs.status in (0, 1) and subs.sync_type = 1
                or subs.srvid = -1)

    update dbo.sysarticles
       set status = status | 1
     where artid in
        (select subs.artid
           from syssubscriptions subs
     inner join dbo.sysarticles arts
             on subs.artid = arts.artid
          where arts.pubid = @pubid)

    update dbo.sysschemaarticles
       set status = status | 1
     where artid in
        (select subs.artid
           from syssubscriptions subs
     inner join dbo.sysschemaarticles arts
             on subs.artid = arts.artid
          where arts.pubid = @pubid)

    exec @retcode = sys.sp_replflush
    return @retcode
end

 
Last revision 2008RTM
See also

  sp_MSdrop_repltran (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