Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSenum_replqueues

  No additional text.


Syntax
create procedure sys.sp_MSenum_replqueues
(
    @curdistdb    sysname = NULL
)
as
begin
    declare @distbit int
    declare @db_name sysname
    declare @cmd nvarchar(1024)

    select @distbit = 16

    
    -- create the temp table to store the relevant information
    
    create table #replqueue (
        queue_server sysname collate database_default not null,
        queue_id sysname collate database_default not null,
        dist_db sysname collate database_default not null
    )
    create unique clustered index ucreplqueue ON #replqueue (queue_id)

    
    -- Has the user specified a distribution database
    
    if (@curdistdb is NULL)
    begin
        
        -- Go through all the distribution databases
        
        declare hCdatabase CURSOR LOCAL FAST_FORWARD FOR
            select name from master.dbo.sysdatabases
            where
                category & @distbit <> 0 and
                has_dbaccess(name) = 1
            for read only
    end
    else
    begin
        
        -- User specified Distribution Database
        -- Validate the user specified name
        
        if exists (select name from master.dbo.sysdatabases
        where
            name = @curdistdb and
            category & @distbit <> 0 and
            has_dbaccess(name) = 1)
        begin
            declare hCdatabase CURSOR LOCAL FAST_FORWARD FOR
            select @curdistdb
            for read only
        end
        else
        begin
            
            -- Error : Invalid distribution db specified
            
            raiserror(20587, 16, 4, N'@curdistdb', N'sp_MSenum_replqueues')
            return 1
        end
    end

    
    -- Enumerate
    
    open hCdatabase
    fetch next from hCdatabase into @db_name
    while (@@fetch_status <> -1)
    begin
        select @cmd =
        'SET NOCOUNT ON ' +
        'INSERT INTO #replqueue (queue_server, queue_id, dist_db) ' +
        'SELECT queue_server, queue_id, ' +
                'N''' + replace(@db_name, '''', '''''') + ''' ' +
        'FROM ' +
                QUOTENAME(@db_name) + '.dbo.MSdistribution_agents ' +
        'WHERE ' +
                'queue_id IS NOT NULL and queue_id != N''mssqlqueue'''

        exec (@cmd)
        fetch next from hCdatabase into @db_name
    end
    close hCdatabase
    deallocate hCdatabase

    
    -- select the contents of the temp table to present
    -- the formatted queue name
    
    select     N'DIRECT=OS:' + queue_server + N'\PRIVATE$\' + queue_id AS 'queue_format'
            ,dist_db
    from #replqueue

    
    -- cleanup
    
    drop table #replqueue
end

 
Last revision 2008RTM
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