I am wanting to process records for dates on an everyday basis. However I have a solution that will work incrementally but I need one that will load the first date if the table is null. Here is my query
SELECT DateToProcess = MIN(MonthlyDate) FROM ods.CustomerBill b WHERE b.MonthlyDate > @DateToProcess
If @DateToProcess
is null I want to set it to say 1999-01-01 that way it grabs the min date from my table and starts inserting records. How can I implement this additional logic to make this work?
Advertisement
Answer
Just wrap @DateToProcess
with an ISNULL
:
ISNULL(@DateToProcess,'19000101')