Step 1 - Input exception rates for one matter. Then view the exception rates in SQL. We want to copy the last row with the effective date of 5/1/2004.
SELECT * FROM mexrate WHERE mrmatter='2000-001'Results
mrmatter | mrtk | mreffdate | mrrate | mrdevper | mrdevdol | mrccode | mrtitle | mrmaximum | mrreason | mrrtnum |
---|---|---|---|---|---|---|---|---|---|---|
2000-001 | ! | 2000-01-01 00:00:00.000 | 200.000 | NULL | NULL | ! | Senior Partner | N | NULL | NULL |
2000-001 | ! | 2003-01-01 00:00:00.000 | 250.000 | NULL | NULL | ! | Senior Partner | N | NULL | NULL |
2000-001 | ! | 2003-03-01 00:00:00.000 | 300.000 | NULL | NULL | ! | Senior Partner | N | NULL | NULL |
2000-001 | ! | 2003-05-01 00:00:00.000 | 350.000 | NULL | NULL | ! | Senior Partner | N | NULL | NULL |
2000-001 | ! | 2004-04-01 00:00:00.000 | 400.000 | NULL | NULL | ! | Senior Partner | N | NULL | NULL |
2000-001 | ! | 2004-05-01 00:00:00.000 | 500.000 | NULL | NULL | ! | Senior Partner | N | NULL | NULL |
Step 2 - Create temporary table to hold matters that need the exception rates & populate.
CREATE TABLE ##mexrate1 ( mmatter VARCHAR(15)); INSERT INTO ##mexrate1 VALUES ('2000-003') INSERT INTO ##mexrate1 VALUES ('2000-010') ... --If there is a systematic way to identify the matters then you can use: INSERT INTO ##mexrate1 SELECT mmatter FROM matter WHERE ...(your criteria)...Step 3 - Execute cursor update below to cycle through the matters and insert new exception rates
BEGIN TRANSACTION mexrateupdate Declare c Cursor For Select Distinct mmatter From ##mexrate1 Open c DECLARE @MatId VARCHAR (15); Fetch next From c into @MatId While @@Fetch_Status=0 Begin INSERT INTO mexrate SELECT @MatId, mrtk, mreffdate, mrrate, mrdevper, mrdevdol, mrccode, mrtitle, mrmaximum, mrreason, mrrtnum FROM mexrate WHERE mrmatter = '2000-001' --The original matter to copy AND mreffdate = '5/1/2004' --The exception rates to copy Fetch next From c into @MatId End Close c Deallocate cStep 4 - Use SQL to view a matter that was updated & make sure everything looks good
SELECT * FROM mexrate WHERE mrmatter = '2000-010'Step 5 - Check the matter in Elite to make sure everything looks ok.
Step 6 - If it's all good, commit the transaction (if not, rollback)
ROLLBACK TRANSACTION mexrateupdate --if it's bad COMMIT TRANSACTION mexrateupdate --if it's goodStep 7 - Explicitly drop the temporary table
DROP TABLE ##mexrate1Step 8 - Be thankful you didn't have to manually input 25 exception rates for 75 matters...
DISCLAIMER - As always, test liberally in a test environment and deploy cautiously.
No comments:
Post a Comment