USP_REPORT_SPONSORSHIPBATCHEXCEPTIONREPORT

Parameters

Parameter Parameter Type Mode Description
@BATCHID uniqueidentifier IN

Definition

Copy

create procedure dbo.USP_REPORT_SPONSORSHIPBATCHEXCEPTIONREPORT(@BATCHID uniqueidentifier) with execute as owner 
as

  declare @TABLENAME nvarchar(128)
    declare @SQL nvarchar(4000);

    begin try
      select @TABLENAME = dbo.UFN_BATCH_GETREPORTTABLENAME(@BATCHID, 1)
      if @TABLENAME is null or OBJECT_ID(@TABLENAME) is not null
    begin
          set @SQL = N'set nocount on;
           select
                  ORIGINALBATCHNUMBER,                 
                  OWNER,
            CONSTITUENTNAME,
            CONSTITUENTLOOKUPID,
            AMOUNT,
            PAYMENTMETHOD,
            REASON EXCEPTION
              from dbo.' + @TABLENAME + '';  

          exec sp_executesql @SQL;
    end
    end try
    begin catch
        exec dbo.USP_RAISE_ERROR;
        return 1;
    end catch

return 0;