More work on SQL consolidation