Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MScopyscriptfile

  No additional text.


Syntax


-- Name: sp_MScopyscriptfile

-- Descriptions:

-- Parameters: as defined in create statement

-- Returns: 0 - success
--          1 - Otherwise

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

create procedure sys.sp_MScopyscriptfile
(
    @scriptfile nvarchar(4000),
    @cmd nvarchar(4000) OUTPUT
)
as
begin
    set nocount on
    declare @directory nvarchar(4000)
                ,@filename nvarchar(1024)
                ,@subdirectory nvarchar(1024)
                ,@retcode int
                ,@distributor sysname
                ,@dist_rpcname sysname
                ,@distribdb sysname
                ,@distproc nvarchar(517)

    IF @scriptfile IS NULL
    BEGIN
        RAISERROR (14043, 16, -1, '@scriptfile', 'sp_MScopyscriptfile')
        RETURN (1)
    END
    
    -- Get distributor details
    
    EXEC @retcode = sys.sp_helpdistributor @distributor = @distributor OUTPUT,
                                            @distribdb = @distribdb OUTPUT,
                                            @rpcsrvname = @dist_rpcname OUTPUT ,
                                            @directory = @directory OUTPUT
    if @@error <> 0 OR @retcode <> 0 or @distributor IS NULL OR @distribdb IS NULL
    BEGIN
        RAISERROR (14071, 16, -1)
        RETURN (1)
    END
    
    -- prepare the directory
    
    select @subdirectory = convert(nvarchar(64), getdate(), 121)
    select @subdirectory = replace(@subdirectory, N'-', N'')
    select @subdirectory = replace(@subdirectory, N' ', N'')
    select @subdirectory = replace(@subdirectory, N':', N'')
    select @subdirectory = replace(@subdirectory, N'.', N'')
    if(right(@directory, 1) = N'\')
        select @directory = @directory + @subdirectory
    else
        select @directory = @directory + N'\' + @subdirectory
    
    -- create the directory and copy the scriptfile on distributor
    
    select @distproc = quotename(@dist_rpcname) + N'.' + quotename(@distribdb) + N'.dbo.sp_MSreplcopyscriptfile'
    exec @retcode = @distproc @directory = @directory, @scriptfile = @scriptfile
    if @@error<>0 or @retcode<>0
        return 1
    
    -- Prepare command, to be posted to log
    
    select @filename = right(@scriptfile, charindex(N'\', reverse(@scriptfile)))
    if(left(@filename, 1) = N'\')
        select @cmd = @directory + @filename
    else
        select @cmd = @directory + N'\' + @filename
    
    -- all done
    
    return 0
end

 
Last revision 2008RTM
See also

  sp_MScopyscriptfile_merge (Procedure)
sp_MSdrop_replcom (Procedure)
sp_MSrepl_addscriptexec (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