If a task is related to an archived matter, mark it as complete

If a task is related to an archived matter, mark it as complete

The following will mark all tasks that are related to a closed/archived matter as Complete. 

  1. --The client has a bunch of tasks related to archived matters.
  2. --These tasks are NOT follow-ups and they NEVER intend on completing them.
  3. --The client would like us to close them out.
  4. UPDATE
  5. __M_Tasks
  6. SET
  7. Final_Stage = 'Complete'
  8. FROM
  9. __M_Tasks V1,
  10. __M_Tasks_Related_Entities V2,
  11. __M_Matters V3
  12. WHERE 1=1
  13. AND V1.Id = V2.Final_TaskEntry_Id
  14. AND V2.Final_RelatedTo_Id = V3.Id
  15. AND V2.Final_RelatedTo_Type = '__M_Matters'
  16. AND V3.Final_Status = 'Archived'