Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSdrop_merge_agentid

  No additional text.


Syntax
CREATE PROCEDURE sys.sp_MSdrop_merge_agentid
(
    @agent_id int
)
AS
begin

    SET NOCOUNT ON

    DECLARE @name           nvarchar(100)
    DECLARE @job_id			binary(16)
    DECLARE @job_step_uid	uniqueidentifier
    DECLARE @local_job		bit
    declare @retcode		int

    SELECT @name = name, @job_id = job_id, @job_step_uid = job_step_uid, @local_job = local_job
    FROM dbo.MSmerge_agents
    WHERE id = @agent_id

    -- Delete Perfmon instance
    dbcc deleteinstance ("SQL Replication Merge", @name)

	delete from dbo.MSmerge_history where session_id in (
		select session_id from
		dbo.MSmerge_sessions where agent_id = @agent_id)
		
	delete from dbo.MSmerge_articlehistory where session_id in (
		select session_id from
		dbo.MSmerge_sessions where agent_id = @agent_id)
		
	delete from dbo.MSrepl_errors where session_id in (
		select session_id from
		dbo.MSmerge_sessions where agent_id = @agent_id)
	
	-- delete sessions associated with the agent that is to be deleted
	delete dbo.MSmerge_sessions where agent_id = @agent_id
	IF @@ERROR <> 0
    	return 1

    -- Remove agent entry
    delete dbo.MSmerge_agents WHERE id = @agent_id
    IF @@ERROR <> 0
        return 1
        	
	if @local_job = 1
    begin
        if exists (select * from msdb.dbo.sysjobs_view where job_id = @job_id)
        begin
            exec @retcode = sys.sp_MSdrop_repl_job @job_id = @job_id,
            										@job_step_uid = @job_step_uid
            if @@error <> 0 or @retcode <> 0
                return 1
        end
    end

    return 0
end

 
Last revision 2008RTM
See also

  sp_dropanonymoussubscription (Procedure)
sp_instdist (Procedure)
sp_MScleanup_agent_entry (Procedure)
sp_MScleanup_subscription_distside_entry (Procedure)
sp_MSdrop_anonymous_entry (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