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 |
Sonu619
Posting Yak Master
202 Posts |
Posted - 2012-08-07 : 15:49:04
|
Hi Guys, Quick Question I create one store procedure and its taking 3m to execute. What i am doing in S.P, Getting data from Sales1 table and insertintoTemp1 table, Second getting data from Sales2 to and insertinto Temp2 table. Clean or using some condition in Temp1 table and insert into Temp3 table.same thing with Temp2 and inserting into Temp4 and then 9 Update statment on Temp4 table and at the last Joining Temp3 and Temp4 to my final resultwith Parameter that i used Start_Date and End_Date. My question is, is there a best and fast way to handle this kinda scnereo?Its fast to four different table and use delete the data everytime S.P run or Temptable table is fast?Thanks for Help. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-07 : 15:54:57
|
why not appear filtering conditons initially itself while loading tables? by doing so you would save two temporary tables and also fetches only required amount of data for further processing. i dont think you need so many steps and so many temporary tables. so if you can explain what exactly you're trying to do i may be able to suggest better way------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
Sonu619
Posting Yak Master
202 Posts |
Posted - 2012-08-07 : 16:07:47
|
Thanks for reply, First Temp1 table is a main table with @Start_Date & @End_Date. So First step I got what I need mean my date selection. In first step I am filtering data. Second Step Create Temp2 table with different tables from First step.Third Step Create Temp3 table from Temp1 table with extra and different calculation. I can’t do this Calculation in first place. Fourth Step Create Temp4 table rom Temp2 table with extra calculations. Again I can’t do this calculation in Temp2 table. Fifth step use 9 update statements ( I think I can use this step earlier) does it make difference if I use this step after step1 or after step 4 ?At the last combine Table 4 and Table3And last drop all four temp tables.Any Advice? |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-07 : 16:16:21
|
Second Step Create Temp2 table with different tables from First step.why do you need this again? you already merged data onto table1 isnt it?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
Sonu619
Posting Yak Master
202 Posts |
Posted - 2012-08-07 : 16:23:11
|
In Second Step I am doing the same thing like First step except My Source is different tables from First step.First Step and Second Step has different tables... |
 |
|
|
|
|