Anyone know a way to make this code run quicker? It is joining two huge tables? There might not be a way but just curious if someone seems something select distinct a1.colA, a2.colB, a2.colC, a2.colD , a2.colE, a2.colF, ` `a2.colG, a2.colH, a2.colI, a2.colJ, a2.colK into ##temp_table3 from ##temp_table1 a1 cross join ##temp_table2 a2 week acct reporting 1 23 50 2 23 43 5 23 36 6 23 45 I am using the cross join because I need to get it to report for weeks 3 and 4 that is it's 0...Right now it skipping weeks 3 and 4 in my dataset because there was no reporting.
Flat out, you won't be able to make a CROSS JOIN without a WHERE clause run faster. It's everything on everything. You are strictly down to how much memory you have and how fast are your disks. You would have to change what you're doing entirely to even have the opportunity for code or index enhancements.