port of cohort$comprehensive_long to SQL Server