Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Kimi86
Yak Posting Veteran
79 Posts |
Posted - 2012-05-15 : 12:01:08
|
I have 3 temp tables created for a bigger logic. The tables look like this#T1 channel q_key ans_key desc Latest_date_keyFASTTRADE 236165 196845 Limited 04/05/2012FASTTRADE 236165 196846 Partnership 24/03/2012FASTTRADE 236165 196848 Public Limited 03/03/2012 #T2 channel q_key ans_key desc First_date_keyFASTTRADE 236165 196845 Limited 04/05/2012FASTTRADE 236165 196846 Partnership 24/03/2012FASTTRADE 236165 196848 Public Limited 03/03/2012 #T3 channel q_key ans_key desc CountsFASTTRADE 236165 196845 Limited 3FASTTRADE 236165 196846 Partnership 3FASTTRADE 236165 196848 Public Limited 6These are only a subset and the actual tables have 14000 plus records.I need to create a report to merge these subsets into one by joining on q_key,ans_key and channel.Though this may seem easy the query takes a lot of time and takes more than 2 hrs to run.. I guess this is due to the join on channel which is a varchar.What possibly can i do to deal with this issue?? |
|
vijays3
Constraint Violating Yak Guru
354 Posts |
Posted - 2012-05-15 : 14:28:24
|
Instead of creating a Temp table Try to build your logic on Derived tables and create proper indexes wherever you apply joins.Vijay is here to learn something from you guys. |
 |
|
|
|
|