UFN_EMAIL_ISANOTHERPROCESSWORKINGONJOB
Checks if any other email process is working on the same job.
Return
Return Type |
---|
bit |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@QUEUEID | uniqueidentifier | IN | |
@INSTANCEID | uniqueidentifier | IN |
Definition
Copy
CREATE function dbo.UFN_EMAIL_ISANOTHERPROCESSWORKINGONJOB(@QUEUEID uniqueidentifier, @INSTANCEID uniqueidentifier)
returns bit
with execute as owner
as begin
declare @SQL nvarchar(1000);
declare @NUMBER integer = 0;
declare @TABLENAME nvarchar(255);
set @TABLENAME = dbo.UFN_GENERALPURPOSEEMAIL_GETDATATABLENAME(@QUEUEID)
set @SQL = 'if object_id(''' + @TABLENAME + ''') is not null select @NUMBER = count(*) from ' + @TABLENAME + ' where INSTANCEID <> ''00000000-0000-0000-0000-000000000000'' and INSTANCEID <> ''' + cast(@INSTANCEID as nvarchar(36)) + '''';
exec sp_executesql @SQL, N'@NUMBER integer output', @NUMBER output;
declare @ISANOTHERPROCESSWORKING bit;
if @NUMBER < 1
begin
set @ISANOTHERPROCESSWORKING = 0;
end
else
begin
set @ISANOTHERPROCESSWORKING = 1;
end
return @ISANOTHERPROCESSWORKING;
end