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 |
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2009-06-04 : 12:18:22
|
| Hi,I have a select statement with some joins whose result is to be used twice in insert part and update part of a table. I found two options for accomplishing this.1. To store the result of select statements into a table Variable and join that table variable in insertion part and updation part.2. keep select statement with joins as derived table and join that derived table while insertion part and updation part.Which method is more efficient?? orThe difference in performance is negligible?? Please advice |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-06-04 : 12:30:20
|
| using derived table means you've to repeat code on both places. i would use a table variable in this scenario to store the result of query and then join to this table on insert and update. |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2009-06-04 : 12:34:53
|
| yaa i too felt the same thing...Anyway thank you very much for ur advice... |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-06-04 : 12:36:16
|
| welcome |
 |
|
|
|
|
|