Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSdrop_qreader_agent

  No additional text.


Syntax
create procedure sys.sp_MSdrop_qreader_agent
(
    @agent_id int = NULL
) AS
BEGIN
    SET NOCOUNT ON
    
    -- Declarations.
    
    DECLARE @retcode        int
    DECLARE @job_id         binary(16)
    DECLARE @job_step_uid	uniqueidentifier
    DECLARE @name           nvarchar(100)
    DECLARE @database       sysname

    select @database = db_name()

	IF @agent_id is NULL
	BEGIN
		SELECT TOP 1 @agent_id = id
			FROM MSqreader_agents
	END

    -- get the agent and job ids
    SELECT @job_id = job_id, @name = name, @job_step_uid = job_step_uid
    FROM MSqreader_agents
    WHERE id = @agent_id

    if (@agent_id is NULL)
        return (0)

    -- Delete Perfmon instance
    dbcc deleteinstance ('SQL Replication QueueReader', @name)

    BEGIN TRAN sp_MSdrop_qreader_agent

    -- delete job for the agent
    IF EXISTS (SELECT * FROM msdb.dbo.sysjobs_view WHERE job_id = @job_id)
    BEGIN
        -- Checks if the job name was generated
        EXEC @retcode = sys.sp_MSisqueuereaderjobnamegenerated
                            @job_id = @job_id

        IF @@ERROR != 0
            GOTO UNDO

        -- Only drop the job if the name was generated
        IF @retcode = 0
        BEGIN
            EXEC @retcode = sys.sp_MSdrop_repl_job @job_id = @job_id,
            										@job_step_uid =  @job_step_uid
            IF (@@ERROR != 0 or @retcode != 0)
                GOTO UNDO
        END
    END

    -- Remove agent entry
    DELETE MSqreader_agents WHERE id = @agent_id
    IF (@@ERROR != 0)
        GOTO UNDO

    -- Remove associated history
    DELETE MSqreader_history
    WHERE agent_id = @agent_id
    IF (@@ERROR != 0)
        GOTO UNDO

    COMMIT TRAN sp_MSdrop_qreader_agent
    RETURN(0)

UNDO:
    ROLLBACK TRAN sp_MSdrop_qreader_agent
    return(1)
END

 
Last revision 2008RTM
See also

  sp_dropdistributiondb (Procedure)
sp_instdist (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