Access the answers to your technology questions today.
Subscribe Now
30-day free trial. Register in 60 seconds.
What Makes Experts Exchange Unique?
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.
Try it out and discover for yourself.
Subscribe Now
30-day free trial. Register in 60 seconds.
Join the Community
Give a Little. Get a Lot.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Join the Community
by: dragos_craciunPosted on 2008-06-02 at 07:57:43ID: 21692559
Well ... I see nothing wrong or inefficient in this query.
Do you have performance problems?
Did you do any test with "real life" data to test the speed?
Can you post the execution plan?
Alternatively you can use MERGE, something like:
MERGE INTO TableA x
USING
(
select a.fielda, a.fieldb, b.fieldc, b.fieldd, a.season, a.sty_num, a.sty_qual
from pro.sty_defs a, pro.loc_defs b
where a.con_num = b.loc_num
) n
ON
(x.sty_qual = n.sty_qual and x.sty_num = n.sty_num and x.season = n.season)
when matched then update set
x.desta = n.fielda, x.destb = n.fieldb, .......
you should collect statistics and test which is faster.
Also, please not that merge will update only the records in TableA for which there is any corresponding data in pro.sty_defs and pro.loc_defs, while the update writtenn as you wrote it will update all the records, setting the "orphaned" ones to NULL.