USP_RECORDOPERATION_BUSINESSPROCESSJOBSCHEDULEDELETE_OPERATION

Executes the "Business Process Job Schedule: Delete" record operation.

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN Input parameter indicating the ID of the record being deleted.
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the delete.

Definition

Copy


CREATE procedure dbo.USP_RECORDOPERATION_BUSINESSPROCESSJOBSCHEDULEDELETE_OPERATION(@ID uniqueidentifier, @CHANGEAGENTID uniqueidentifier)
with execute as caller
as
    set nocount on;

  -- Delete row from schedule to user mapping table

  delete from dbo.BUSINESSPROCESSJOBSCHEDULEUSERMAPPING 
  where JOBSCHEDULEID = 
  (select JS.schedule_id
  from msdb.dbo.sysjobs J
  inner join msdb.dbo.sysjobschedules JS on JS.job_id = J.job_id
  where J.job_id = @ID)

    exec msdb.dbo.sp_delete_job @job_id = @ID, @delete_unused_schedule = 1;