I've created a task scheduler and based on certain conditions tasks will be scheduled into a database. Below is a sample which basically adds a task occurrence every weekday for 2500 iterations which turns out to be approx 7 years.
Code:
Case 3
For x = 0 To 2499
Day = sd + x
DayOfWeek = Weekday(Day)
If DayOfWeek = 2 Or DayOfWeek = 3 Or DayOfWeek = 4 Or DayOfWeek = 5 Or DayOfWeek = 6 Then
SQLAddOccurrence3 = "INSERT INTO [BMS_OCCURRENCE] (TaskID,TaskName, Day, Owner, Deadline1, Deadline2, Deadline3, Deadline4)" & _
"VALUES('" & TaskID & "', '" & TN & "', '" & Day & "', '" & OW & "', '" & d1 & "', '" & d2 & "', '" & d3 & "', '" & d4 & "');"
DoCmd.SetWarnings False
DoCmd.RunSQL SQLAddOccurrence3
DoCmd.SetWarnings True
End If
Next x
The code executes properly. The issue is that when I run this locally it executes within 4 seconds. It takes 75 seconds to run this on the network. I had the DBA in my office and he did not provide me any solutions other than to update it as a batch instead of writing to the table at the end of each loop. I'm not sure how to go about a batch update; would anybody be able to help me out? I would appreciate any suggestions or help. Thanks!