SYMPTOM:
When using SQL Server 2008, intermediate tables are not created as temporary tables. In SQL Server 2008 temporary tables will typically be created with a hashtag/pound (#) sign in front of the table name as in the example below. The hashtag signals to the database that the table is created as a temporary table.
select a11.EMP_ID EMP_ID, sum(a11.TOT_DOLLAR_SALES) Revenue, sum(a11.TOT_COST) WJXBFS1, sum((a11.TOT_DOLLAR_SALES - a11.TOT_COST)) WJXBFS2, rank () over ( order by sum(a11.TOT_DOLLAR_SALES) desc) WJXBFS3 into #ZZMD00
create table ZZMD00; WITH (DISTRIBUTION = HASH(EMP_ID))as select a11.EMP_ID EMP_ID, sum(a11.TOT_DOLLAR_SALES) Revenue, sum(a11.TOT_COST) WJXBFS1, sum((a11.TOT_DOLLAR_SALES - a11.TOT_COST)) WJXBFS2, rank () over ( order by sum(a11.TOT_DOLLAR_SALES) desc) WJXBFS3
