i need to update suppID column on ordersTB table from suppTB table. tables shown below:
suppTB
suppID ,suppName , itemID ,....
ordersTB
itemID, suppID(added later so mostly null's)...
what the most efficient way to update this table. i tried this query from old Q's here (How can I do an UPDATE statement with JOIN in SQL?) ,but it executing over a day and still running
UPDATE ordersTB
SET A.suppID = B.suppID
FROM ordersTB as A
JOIN suppTB as B
ON A.itemID = B.itemID
WHERE A.suppID is null
other notes & things i tried:
- both tables are huge size (tens of millions)
- itemID & suppID columns are indexed. i remove the indexs before the update to make it faster. still take too long.
- also try MERGE query. same results..