Title: Refactoring Legacy T-SQL for Improved Performance