Delete a specific Batch Job

I wrote some time ago about cleaning up the batch jobs in AX Batch jobs troubleshoot.html, but that involved deleting the entire set of batch jobs, and needed this time to only delete the workflow batch job.


So, the sql script to only delete a specific entry would be:

declare @BatchJobRecId bigint

select top 1 @BatchJobRecId = RECID from BATCHJOB
    where CAPTION = 'Workflow message processing' and
            COMPANY = 'dat'

delete from BATCHJOB where RECID = @BatchJobRecId

delete from BATCH where BATCHJOBID = @BatchJobRecId 


if (exists(select top 1 RECID from BATCHJOB where CAPTION = 'Data upgrade'))
begin
    print ''
    print 'There are still other btch jobs registered in AX with this name. Run again this script'
end

No comments:

Post a Comment