[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 152
  • Last Modified:

UPDATING SQL SERVER TABLE

Hello, I have two tables:

ACCESS_OFFERS and ACCESS_PROCESSED

Both tables have a field called ENDDATE and OFFERIDENTIFIER

What I need to do is to update the field ENDDATE at the ACCESS_PROCESSED table where the OFFERIDENTIFIER matches.

I was planning to do a loop for ACCESS_OFFERS and then an update for each OFFERIDENTIFIER, but there is a total of 900,000 records and it takes forever.

Is there a way to do an update with a single sentence? like "update ACCESS_PROCESSED set ENDDATE = ENDATE at ACCESS_OFFERS where OFFERIDENTIFIER matches"?

Thanks!
0
SimpleDude
Asked:
SimpleDude
1 Solution
 
Daniel ReynoldsSoftware Applications Developer / IntegratorCommented:
Give the following a try in your test environment

UPDATE ACCESS_PROCESSED
      SET ACCESS_PROCESSED.ENDDATE = b.ENDDATE
FROM ACCESS_PROCESSED
JOIN ACCESS_OFFERS b ON b.OFFERIDENTIFIER = ACCESS_PROCESSED.OFFERIDENTIFIER
 -- AND ....other join terms.
0
 
AielloJCommented:
SimpleDude:

Do you have to do the update at all?  Why not simply join the tables in your query?  This would save a long update process.

Best regards,

AielloJ
0
 
SimpleDudeAuthor Commented:
Thanks!
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now