Re: Cursor problem for teired pricing



Erland thanks for pointing out the issue with @Trans - (@TransCount -
@VolumeThreshold), that was incorrect. During regular processsing
(Else portion) I should not update the trans field.

After considering the advice received and further analysis of my
scheme I think I am going with a hybrid solution. Let me know what
you think.

1) start a transaction to lock the table current_month_loc_nine
against inserts and updates while processing
2) create a new table (Loc9) with all of the fields as the original
and a Loc9ID column that is an identity, primary key, clustered index.
(I may make this a temp table depending on server memory)
3) copy current_month_loc_nine to Loc9 allowing it to assign Loc9ID to
each row. (This gives we a predictable order and a identity column for
updates) (all 2.8 million records)
4) I will use the single command method from the SQLMag article to
create a temp table (#TEMP) with just the id and accumulated volume
for that company only. (170 k records)
5) Do an update query that joins Loc9 to #TEMP to set loc9.Rate to the
low volume rate where volume <= @VolumeThreshold)
6) Do an update query that joins Loc9 to #TEMP to set loc9.Rate to the
high volume rate where volume > @VolumeThreshold)
7) if needed split the threshold record into 2 (one with the low
volume rate and insert the remaining recordsin a new record with the
high volume rate).
8) Truncate the original current_month_loc_nine table, then copy the
Loc9 (w/o Loc9ID) into the now empty table.
9) Drop my Loc9 and #TEMP tables
10) Commit transaction

.



Relevant Pages

  • Re: Cant delete temp files
    ... went through the process of stopping each start-up program and was able to ... So you are one of those who has this %temp% growing on bootup/switch-on - ... So I cannot get a build up test with Disk Cleaner. ... Then two days after the updates, I went in to clean it and they had all gone ...
    (microsoft.public.windowsxp.basics)
  • Re: Need expert coding help with a debugging issue.
    ... I built a check code to verify which user had accessed the temp table most ... database updates that table with the current username. ... GoTo FiveSecDelay ...
    (microsoft.public.access.formscoding)
  • Query works in QA, but NOT in SQL Server stored proc?!
    ... Ok...below is a simple query that inserts some records into a temp ... table then updates another table using the temp table. ... in Query Analyzer, but refuses to save in SQL Servers' stored procedure ... GROUP BY doc, POE ...
    (microsoft.public.sqlserver.programming)
  • Re: Computer Comment, Please?
    ... Searched all the temp folders and the auto-save location ... Word *always* creates a temp file that handles the work you're doing. ... major office updates. ... It's a reliable setup, usually. ...
    (alt.guitar.bass)