Synthesize Missing Practice Areas

Synthesize Missing Practice Areas

The following SQL script will create practice areas where they do not exist in the Matters table.

  1. --Synthesize missing practice areas from Matters
  2. INSERT INTO __M_Matters_PracticeAreas(
  3. Id,
  4. Final_Subject
  5. )
  6. SELECT DISTINCT
  7. Final_PracticeArea_Id,
  8. Final_PracticeArea_Id
  9. FROM
  10. __M_Matters
  11. WHERE 1=1
  12. AND Final_PracticeArea_Id != '' --Ignore Blank Practice Areas
  13. AND Final_PracticeArea_Id NOT IN (SELECT Id FROM __M_Matters_PracticeAreas)