Record counts from the table

  • Jeff Moden wrote:

    I couldn't assume such a thing for possible frequency.  We work with documents and we go through 50,000 documents per day.  The table size never changes because incoming is almost a perfect daily match for outgoing.

    Also, the OP just stated that we can't do a thing with the table directly nor the DataID because it IS a part of a 3rd party product.  That's why I always ask the OP on such things and generally ignore my own presumptions as well as those of others.  People's situations vary so much that I just can't assume even if some assumptions seem totally obvious, especially in light of the very poor form that the DataID column is in.

    Thanks for replying.  Yes yes, very reasoned of course.  I was just trying to keep the ball rolling.  Everything I know about this subject I learned from you Jeff.  Thank you so much.  You wrote this article on MSDN in 2012 and it was forwarded to me by a friend about 2 years ago.  I've studied it a lot because the issues you solved have come up over and over in my projects.  When I read this forum posting it immediately popped into my head.

    https://blogs.msdn.microsoft.com/mvpawardprogram/2012/06/25/hierarchies-convert-adjacency-list-to-nested-sets/

    My solution to the OP is based on your article but uses Json (so it's 2016+ only).  Instead of the sortpath being an enumerated byte array which gets split using a tally tvf, it uses CROSS APPLY to iterate the inner recursions and to serialize the downlines to Json arrays.  Because the OP's using Sql 2014 I'm thinking one possible solution would be to exactly follow your article.

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

Viewing post 16 (of 15 total)

You must be logged in to reply to this topic. Login to reply