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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update query taking forever

Status
Not open for further replies.

nollieflip

Programmer
Aug 22, 2003
5
US
I have the the following update running and it seems to be running too long. I've let it go 20 minutes and it still hadn't finished. It updates about 45,000 records.

UPDATE BuildAccount
SET EmailAddress1 = (SELECT EmailList.EmailStandard FROM EmailList WHERE BuildAccount.AccountNumber = EmailList.Account + right('0000' + EmailList.Location, 4))
 
Perhaps an inner join would be faster than the subquery, so:
UPDATE BuildAccount
SET EmailAddress1 = EmailList.EmailStandard
FROM BuildAccount INNER JOIN EmailList
ON BuildAccount.AccountNumber = (EmailList.Account + RIGHT('0000' + EmailList.Location, 4))

Also, if you use Query Analyzer on this, what does the execution plan optimizer report?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top