I agree, and I like the idea of at least setting up the trigger. The issue that we run into is the application is built for a federal agency. All the hours have to be recorded within 6 minute intervals. Getting the government to approve the spending is a slow process, and because of how our contract is written my company can't do work without explicitly billing.
The good news is I believe I've solved my issue. I have the logic worked out in my head, but I haven't tried it yet. It is ugly, but here's the concept:
Select rvlPropertyID
Max(StatusDate) As MaxDate
Into #TempDataHolder
From dbo.rvlPropertyAccess
Select TDH.rvlPropertyID
,TDH.MaxDate
,rPA.Status
,Row_Number() As RowNum
Into #TempDataHolder2
From #TempDataHolder TDH Inner Join dbo.rvlPropertyAccess rPA
On TDH.rvlPropertyID = rPA.rvlPropertyID
And TDH.MaxDate = rPA.StatusDate
Group By TDH.rvlPropertyID
,TDH.MaxDate
,rPA.Status
With CTE
(ID,RowNum)
As
(Select rvlPropertyID
,Max(RowNum)
From #TempDataHolder2)
Select TDH2.rvlPropertyID
,TDH2.StatusDate
,TDH2.Status
From #TempDataHolder2 TDH2 Inner Join CTE
On TDH2.rvlPropertyID = CTE.rvlPropertyID
And TDH2.RowNum = CTE.RowNum
That's the logic anyway. I'll see how it goes, and post the final results.
[font="Arial"]“Any fool can know. The point is to understand.”
- Albert Einstein
"DOH!"
- Homer Simpson[/font]