UFN_EMAIL_ISPROCESSINGTABLEEMPTY

Returns true if the processing table contains zero rows.

Return

Return Type
bit

Parameters

Parameter Parameter Type Mode Description
@QUEUEID uniqueidentifier IN

Definition

Copy


      CREATE function dbo.UFN_EMAIL_ISPROCESSINGTABLEEMPTY(@QUEUEID 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 + ';'

          exec sp_executesql @SQL, N'@NUMBER integer output', @NUMBER output;

          declare @ISTABLEEMPTY bit;

          if @NUMBER < 1
          begin
              set @ISTABLEEMPTY = 1;
          end
          else
          begin
            set @ISTABLEEMPTY = 0;
          end

        return @ISTABLEEMPTY;
      end