Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update multiple columns using select joins on 2 tables

Status
Not open for further replies.

williey

Technical User
Jan 21, 2004
242
I need a more efficient way to update 5 columns in table 1 using 5 columns from table 2. But the select criteria requires a 2 tables join between 1 and 2.

Eg.

update A a
set (a.col1, a.col2, a.col3, a.col4, a.col5) =
(select b.col1, b.col2, b.col3, b.col4, b.col5
from B b
where a.col10 = b.col10
and a.col11 = b.col11
and a.col12 = b.col12)

The above method takes too long to update 5 columns with about 40k rows.

 
If you haven't done so already, you might want to consider a composite index on col10, col11, and col12 of both tables.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top