Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSgetpartitionsnapshotfolder

  No additional text.


Syntax

-- Name: sp_MSgetpartitionsnapshotfolder

-- Description: This function mimics the snapshot agent to get
--              the snapshot folder for a given publication

-- Parameters:  @publisher  sysname

-- Returns: nvarchar(255)

-- Security:
-- Requires Certificate signature for catalog access

-- This is an internal function

create procedure sys.sp_MSgetpartitionsnapshotfolder(
    @publication sysname,
    @suser_sname sysname,
    @host_name sysname,
    @partition_id int,
    @snapshot_folder nvarchar(255) OUTPUT)
as
begin
    declare @snapshot_folder_long nvarchar(4000)
    declare @working_dir nvarchar(400)
    declare @retcode int
    declare @enabled_for_internet bit
    declare @snapshot_in_defaultfolder bit
    declare @shellcommand nvarchar(4000)
    declare @publisher sysname
    declare @publisher_db sysname

    select @publisher = publishingservername()
    select @publisher_db = db_name()

    if not exists (select pubid from dbo.sysmergepublications
        where UPPER(publisher) collate database_default = UPPER(@publisher) collate database_default
            and publisher_db = @publisher_db and name = @publication)
	begin
		RAISERROR (20026, 16, -1, @publication)
		return (1)
	end

    -- first check if the publication has an alternate snapshot folder
    -- if so use that.
    select @working_dir = alt_snapshot_folder,
             @enabled_for_internet = enabled_for_internet,
             @snapshot_in_defaultfolder = snapshot_in_defaultfolder from dbo.sysmergepublications
    where publisher = @publisher and publisher_db = @publisher_db and name = @publication

    if @working_dir is null or @working_dir = ''
    begin
        exec @retcode = sys.sp_helpdistributor @directory = @working_dir output
        if @@error<>0 or @retcode<>0 or @working_dir is NULL
            return 1
    end

    -- determine whether to use unc or ftp subdir. This is based on the "enabled_for_internet" property of
    -- the publication
    if @enabled_for_internet = 0
        select @snapshot_folder_long = @working_dir + '\unc\' +
                 sys.fn_replcomposepublicationsnapshotfolder(@publisher,@publisher_db,@publication,1) collate database_default
    else
        select @snapshot_folder_long = @working_dir + '\ftp\' +
                 sys.fn_replcomposepublicationsnapshotfolder(@publisher,@publisher_db,@publication,1) collate database_default

    set @snapshot_folder_long = @snapshot_folder_long + '\'

    if (len(@snapshot_folder_long) > 230)
        set @snapshot_folder = sys.fn_replgenerateshorterfilenameprefix(@snapshot_folder_long, 230)
    else
        set @snapshot_folder = @snapshot_folder_long

    -- append the partition information to the folder name in order to get a unique name
    set @snapshot_folder = @snapshot_folder + sys.fn_replcomposepartitionfolder(@suser_sname, @host_name, @partition_id) collate database_default + N'\'


    /*
    select @shellcommand = N'if not exist "' + @snapshot_folder +
                               N'" mkdir "' + @snapshot_folder + N'"'
    exec @retcode = master.dbo.xp_cmdshell @shellcommand, no_output
    if @@error<>0 or @retcode<>0
    begin
        return 1
    end
    */
    return 0
end

 
Last revision 2008RTM
See also

  sp_MSaddmergedynamicsnapshotjob (Procedure)
sp_MScreatemergedynamicsnapshot (Procedure)
sp_MSdrop_rladmin (Procedure)
sp_MSrefreshdynamicsnapshotlocations (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