USP_EMAILJOB_DELETE
Executes the "Email Job: Delete" record operation.
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | nvarchar(255) | 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_EMAILJOB_DELETE
(
@ID nvarchar(255),
@CHANGEAGENTID uniqueidentifier
)
with execute as caller
as
set nocount on;
begin try
declare @REALID uniqueidentifier;
set @REALID = cast(substring(@ID,1,36) as uniqueidentifier);
declare @JOBNAME as nvarchar(255);
set @JOBNAME = substring(@ID,38,len(@ID)-36);
exec dbo.USP_BUSINESSPROCESSINSTANCE_DELETE '3269A1D1-31CB-4D28-945C-B7623A3EFCCA', @ID, @CHANGEAGENTID;
exec dbo.USP_GLOBALCHANGE_DELETEBYID_WITHCHANGEAGENTID @ID, @CHANGEAGENTID;
-- delete the sql job as well
if len(@JOBNAME) > 0
begin
begin try
exec msdb.dbo.sp_delete_job
@job_name = @JOBNAME;
end try
begin catch
return 0; -- job may have been deleted externally...
end catch
end;
return 0;
end try
begin catch
exec dbo.USP_RAISE_ERROR;
return 1;
end catch