1: 2: 3: 4:
If (Select Max(InvoiceDate) from bill.dbo.Invoices) > Select Max(InvoicesRecdDate) from [Billing Automation Processes].dbo.billrunstatustable Begin Select Max(InvoiceDate) from bill.dbo.Invoices