Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSrefreshmqtosql

  No additional text.


Syntax
CREATE PROCEDURE sys.sp_MSrefreshmqtosql
(
    @publisher sysname
    ,@publisher_db sysname
    ,@publication sysname
)
as
begin
    set nocount on
    declare @retcode int
                ,@queue_server nvarchar(255)
                ,@agent_id int
                ,@queue_id sysname

    
    -- enumerate the distribution agent entries that are using MSMQ
    -- for this publications
    
    declare #hcdistagents cursor local fast_forward for
        select id, queue_server, queue_id
        from (dbo.MSdistribution_agents as a join sys.servers as s
            on a.publisher_id = s.server_id)
        where upper(s.name) = upper(@publisher)
            and a.publisher_db = @publisher_db
            and a.publication = @publication
            and a.queue_server is not null
            and a.queue_id is not null
            and a.queue_id != N'mssqlqueue'
    for read only
    open #hcdistagents
    fetch #hcdistagents into @agent_id, @queue_server, @queue_id
    while @@fetch_status != -1
    begin
        
        -- drop the msmq
        
        begin try
            exec sys.sp_MSdropmqforsubscription @queue_server, @queue_id
        end try
        begin catch
            
            -- ignore the error here as it is non fatal for refresh process
            
            raiserror(N'Could not drop mq %s %s for agent %d', 10, 1, @queue_server, @queue_id, @agent_id)
        end catch
        
        -- update this entry
        
        update dbo.MSdistribution_agents
        set queue_server = NULL, queue_id = N'mssqlqueue'
        where id = @agent_id
        
        -- update MSsubscriptions entries for subscriptions serviced by this agent
        
        update dbo.MSsubscriptions
        set update_mode = case
                when (update_mode = 2) then 4
                when (update_mode = 3) then 5
                when (update_mode = 7) then 6
                else update_mode end
        where agent_id = @agent_id
        
        -- get next entry
        
        fetch #hcdistagents into @agent_id, @queue_server, @queue_id
    end
    close #hcdistagents
    deallocate #hcdistagents

    
    -- all done
    
    return 0
end

 
Last revision 2008RTM
See also

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