Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_createpalrole

  No additional text.


Syntax
CREATE PROCEDURE sys.sp_createpalrole
(
    @publication sysname
    ,@mode int = 0   -- 0 = merge, 1 = tran
    ,@publisher sysname = NULL -- for hrepl publications
)
AS
BEGIN
    set nocount on
    declare @role sysname
                ,@retcode int
                ,@pubidmerge uniqueidentifier
                ,@pubidtran int
                ,@publisher_type sysname
    
    -- security check
    
    exec @retcode = sp_MSreplcheck_publish
    if @@ERROR <> 0 or @retcode <> 0
        return(1)
    
    -- check @mode
    
    if (@mode not in (0,1))
        return 1
    
    -- publication should exist
    
    if (@mode = 0)
    begin
        select @pubidmerge = pubid from dbo.sysmergepublications
        where name = @publication and publisher_db = db_name()
            and UPPER(publisher) collate database_default = UPPER(publishingservername()) collate database_default
        if (@pubidmerge is NULL)
        begin
            RAISERROR (20026, 16, -1, @publication)
            return (1)
        end
    end
    else
    begin
        -- Get publisher info
        EXEC @retcode = sys.sp_MSrepl_getdistributorinfo
                                                        @publisher      = @publisher,
                                                        @publisher_type = @publisher_type OUTPUT
        IF @@error <> 0
        BEGIN
             RAISERROR (14071, 16, -1)
             return (1)
        END
        -- Restrict specification of publisher to HREPL only
        IF @publisher_type = N'MSSQLSERVER' AND @publisher is not null
        BEGIN
            RAISERROR(21606, 16, -1, '@publisher', 'NULL')
            RETURN (1)
        END

        -- Get publication id
        SELECT @pubidtran = sys.fn_MSrepl_getpubid(@publication, @publisher, @publisher_type)

        if (@pubidtran is NULL)
        begin
            RAISERROR (20026, 16, -1, @publication)
            return (1)
        end
    end
    
    -- Update the PAL role for this publication
    
    if (@mode = 0)
    begin
        exec @retcode = sp_MSrepl_FixPALRole @pubid = @pubidmerge, @role = @role output
    end
    else
    begin
        exec @retcode = sp_MSrepl_FixTranPALRole
                                                @pubid          = @pubidtran,
                                                @publication    = @publication,
                                                @publisher_type = @publisher_type,
                                                @publisher      = @publisher,
                                                @role = @role output,
                                                @reserved      = 1
    end
    if @retcode <> 0 or @@error <> 0
    begin
        RAISERROR (20625, 16, -1, @publication)
        return 1
    end
    
    -- all done
    
    return 0
END

 
Last revision 2008RTM
See also

  sp_createmergepalrole (Procedure)
sp_createtranpalrole (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