Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSrepl_check_server

  No additional text.


Syntax
create procedure sys.sp_MSrepl_check_server (
    @srvname sysname,
    @check_distdb bit = 0
        ) AS
    -- This sp is called by sp_dropserver to check if the server is in use by replication.
    declare @subscriber_bit smallint
    declare @distributor_bit smallint
    declare @retcode int
    declare @proc nvarchar(255)
    declare @dbname sysname

    -- Intialize
    select @distributor_bit = 8
    select @subscriber_bit = 4

    if @check_distdb = 0
    begin
        -- Check to see if the server is marked as a Distributor
        if exists (select * from master.dbo.sysservers where UPPER(srvname) = UPPER(@srvname) collate database_default and
            srvstatus & @distributor_bit <> 0)
        begin
            raiserror(20581, 16, -1, @srvname)
            return (1)
        end
        -- Check to see if the server is a dist publisher
        if object_id('msdb.dbo.MSdistpublishers') is not null
        begin
            if exists (select * from msdb.dbo.MSdistpublishers where
                UPPER(name) = UPPER(@srvname) collate database_default)
            begin
                raiserror(20582, 16, -1, @srvname)
                return (1)
            end
        end
        -- Check to see if the server is in use as a subscriber in the distribution dbs.
        if object_id('msdb.dbo.MSdistributiondbs') is not null
        begin
            declare hCForEachDb CURSOR LOCAL FAST_FORWARD FOR
                select name
                	from msdb.dbo.MSdistributiondbs
                	where HAS_DBACCESS(name) = 1
            FOR READ ONLY
            open hCForEachDb
            fetch hCForEachDb into @dbname
            /* Loop for each database */
            while (@@fetch_status >= 0)
            begin
                select @proc = quotename(@dbname) + '.sys.sp_MSrepl_check_server'
                exec @retcode = @proc
                    @srvname = @srvname,
                    @check_distdb = 1
                if @retcode <> 0 or @@error <> 0
                    return (1)
                fetch hCForEachDb into @dbname
            end /* while FETCH_SUCCESS */
        end
    end
    else
    begin
        if object_id('MSsubscriber_info') is not null
        begin
            declare @publisher sysname
            select @publisher =  publisher from MSsubscriber_info sub
                where UPPER(subscriber) = UPPER(@srvname)
            if @publisher is not null
            begin
                raiserror(20584, 16, -1, @srvname, @publisher)
                return (1)
            end
        end
    end


 
Last revision 2008RTM
See also

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