ms sql Update date a table scanning all records
Posted on 2014-10-12
I have 2 tables.
t1 has 30,000,000 records
t2 has 20,000 records
I do this
update table1 set fieldx=1 from table2 where t1.email=t2.email
t2 is indexed on email
t1 is indexed on email
I realize that the process has to scan the 30,000,000 records to get the matches
I am sure there must be a way to run a query where I scan the 20,000 records of t2 and update t1. Which would be much faster.
In Foxpro I would run al loop for each record in t2 find if the record was in t1 and update it.