Adding Records to SQL Table
Posted on 2014-01-24
I have a table (AGREEMENT) that has details about agreements. Specifically Date_RENTED, DUE_DATE, FREQUENCY
I need to create details in another table for each agreement
AGREEMENT RENTED DUE FREQ
1 1/1/13 2/1/14 M
2 1/1/12 3/1/14 W
I need records for the above agreement #1 for 1/1/13, 2/1/13, 3/1/13, etc. up to the due date. For Agreement 2, it would be 1/1/12, 1/8/12, 1/15/12, etc.
My problem is that while I can do this in a procedure, I have to create a CURSOR for the AGREEMENT TABLE. Since I can't write data via a function, I can't use that to get details.
Using a cursor is painfully slow and I need a solution if one is possible w/out a cursor.
I ran on a test set with 7000+ agreements and it took 2 hours to run. I have a production system with 90000+ agreements.
Anyone have a possible solution to speed up the creation?