A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

My update query is very slow...need help!!



 
 
Thread Tools Display Modes
  #1  
Old June 7th, 2004, 08:31 PM
VC
external usenet poster
 
Posts: n/a
Default My update query is very slow...need help!!

I wrote 7 update queries for updating the field startofweek and endofweek depending on the reportday, it takes more than 2 hrs to run all of them for 250000 records, do anyone knows how to run these 7 queries faster?

for all records with reportday is on SUNDAY
UPDATE mastertable SET mastertable.Startofweek = [REPORTDAY], mastertable.Endofweek = [REPORTDAY]+6
WHERE (((DatePart("w",[REPORTDAY]))=1));

for all records with reportday is on MONDAY
UPDATE mastertable SET mastertable.Startofweek = [REPORTDAY]-1, mastertable.Endofweek = [REPORTDAY]+5
WHERE (((DatePart("w",[REPORTDAY]))=2));
:
:
:
for all records with reportday is on Saturday
UPDATE mastertable SET mastertable.Startofweek = [REPORTDAY]-6, mastertable.Endofweek = [REPORTDAY]
WHERE (((DatePart("w",[REPORTDAY]))=7));








  #2  
Old June 7th, 2004, 09:21 PM
Tasha
external usenet poster
 
Posts: n/a
Default My update query is very slow...need help!!

Just a suggestion.

Make a table called weeks.
Week StartDate EndDate
1 1-1-2004 1-7-2004
2 1-8-2004 1-14-2004
3 1-15-2004 1-21-2004

etc..

Then run one query

UPDATE mastertable SET mastertable.Week = Weeks.Week
WHERE mastertable.[Report Day] Between Weeks.[StartDate] And Weeks.[EndDate]
  #3  
Old June 7th, 2004, 10:15 PM
external usenet poster
 
Posts: n/a
Default My update query is very slow...need help!!

If you have not already done so, index all of the fields
you will be searching in the table.
  #4  
Old June 9th, 2004, 08:44 AM
xuge120
external usenet poster
 
Posts: n/a
Default My update query is very slow...need help!!


"Tasha" ¼¶¼g©ó¶l¥ó
...
Just a suggestion.

Make a table called weeks.
Week StartDate EndDate
1 1-1-2004 1-7-2004
2 1-8-2004 1-14-2004
3 1-15-2004 1-21-2004

etc..

Then run one query

UPDATE mastertable SET mastertable.Week = Weeks.Week
WHERE mastertable.[Report Day] Between Weeks.[StartDate] And

Weeks.[EndDate]


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:56 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.