in reply to T-SQL - use of tmp tables

Firstly this isn’t a Perl question, but more importantly you need to let us know what you are trying to do and what is going wrong. To me it looks like you are simply trying to pull out some data from two tables and hold them in a temp table. If so then try this
SELECT Time_ref, Time_instance, Geo_class, Aggregated_area, Super_classed_disease_cat, Cause, Constraint_ref, Sex, Sex_code, Age_start, Age_end, Age_range, Sum_count = SUM(G.Converted_person_count) INTO #tmp_G_P_M_CC FROM Geo_postaggregated_mortality_count_with_cause_catagory_SPLIT G, Time_definition_SPLIT T WHERE T.Key_m >= 1 AND G.Time_instance = T.Instance_tag GROUP BY G.Time_ref, G.Time_instance, G.Geo_class, G.Aggregated_area, G.Super_classed_disease_cat, G.Cause, G.Constraint_ref, G.Sex, G.Sex_code, G.Age_start, G.Age_end, G.Age_range
Note that this assumes that Time_definition_SPLIT is an integer. If this is way off then you need to give more information