All pastes #382234 Raw Edit

Someone

public sql v1 · immutable
·published 2007-03-05 13:04 UTC
rendered paste body
CREATE TABLE #tempA(...)CREATE TABLE #tempB(...)------------------------------------INSERT INTO #tempBSELECT <some stuff from other tables>FROM	HeadDataLEFT JOIN ...LEFT JOIN ...LEFT JOIN ...------------------------------------INSERT INTO #tempASELECT	A,B,C,D, ..., AB.*, BB.*FROM SomeTable STableLEFT JOIN	#tempB ON  ...LEFT JOIN ...LEFT JOIN ...INNER JOIN ...LEFT JOIN ...WHERE BB.Value IS NULLAND ...AND ...AND ...AND ...AND ...------------------------------------------------------------SET @sql = 'SELECT ' + @FieldList + ' FROM #tempA 'SET @sql = @sql +'GROUP BY ' + @FieldListEXEC sp_Executesql @sql