Wednesday, February 2, 2011

Running Totals in SQL, Back to the Future

I have just discovered a very good article and great discussion about implementing running totals in T-SQL. The discussion is over 200 posts long, but it is worth reading from the beginning to the end with exception of few posts discussing personal issues. Both the discussion and the article are full of impressive investigations and solutions. I wrote in 2006 an article  about the same topic. I must admit that my investigation and solution were not quite as good as I saw in the "future" article. Funny thing about the article is that it is dated in the future (2011/03/04), for a reason I did not quite understand.


Anyway, the purpose of my article was to show that it is better to solve cursor friendly problems on client side then in SQL. If you solve it in SQL you have to choose between slow, resource intensive solution and not quite reliable one. In my opinion, the article by Jeff Moden and the discussion about it confirmed my conclusions from five years ago.