I'm trying to create a SQL CLR function that performs a running total similar to what's explained here:http://www.pawlowski.cz/2010/09/sql-server-and-fastest-running-totals-using-clr/
However, this function only does a running total of all the values in a column. What I'm trying to do is reset the running total so that it goes to 0 whenever there's a transition between field1 (SQL varchar) and field2 (SQL numeric). However, I can't seem to figure out the necessary code to do this. I've tried storing both fields using CallContext, but I keep running into null references. I figured the transition detection would work similarly to the running total calculation, but it doesn't. I've been racking my brain for several hours on this with no luck.
Here's the table that I'm using this function against, the primary key isREF_NO:
CREATETABLE[...