﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Lynn Pettis  / The Dynamic Tally or Numbers Table / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 25 May 2013 13:35:17 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>[quote][b]Jeff Moden (10/2/2009)[/b][hr][code]--===== Find the "gap ranges"     -- This assumes that gaps include any whole number greater than 0 SELECT GapStart = (SELECT ISNULL(MAX(b.MyID),0)+1                      FROM #MyTest b                      WHERE b.MyID &amp;lt; a.MyID),        GapEnd = MyID - 1     FROM #MyTest a  WHERE a.MyID NOT IN (SELECT MyID + 1 FROM #MyTest)[/code]It also doesn't need a mega-row tally table.[/quote]Why do I think the last line of that code should read[code]  WHERE a.MyID NOT IN (SELECT MyID + 1 FROM #MyTest) and a.MyID &amp;gt; 1[/code]edit: I remember now why I hate html, at least with code sets other than unicode.  It is something to do with "&amp;" followed by "gt;" insteard of "&amp;gt;" and other similar inanities.</description><pubDate>Tue, 23 Feb 2010 13:40:00 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>Great article, Lynn.  Extremely interesting, and good clear testing report and data.All those people querying why generate it dynamically amaze me - I wouldn't dream of having a static pre-generated 256 million row tally table in any system I was responsible for (but yes, I do have one with 11k rows, which is useful for many things) so dynamic generation is the only option if I ever need one that big.  Also, from a performance point of view reading a big static Tally table is going to cause head movement on mty discs, whereas using a table valued function may enable me to avoid that IO overhead, so I have at least a chance that dynamic generation will reduce disc load compared to a static table.</description><pubDate>Tue, 23 Feb 2010 12:24:53 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>[quote][b]the sqlist (9/22/2009)[/b][hr]Here is another version that WILL work on any SQL version and the code is pretty much self descriptive and easy to understand by everyone. I agree that might not have ALL the features the code in article has but almost all. Still has the start/end/increment values[/quote]Actually the start/end/increment values don't quite work because of this little code fragment[quote]		where			number between @pStartValue and @pEndValue			and number % @pIncrement = 0[/quote]that last line should have been [code]                      and (number - @pStartValue) % @pIncrement = 0 [/code]so that it's possible to get, for example, a sequence like 5,8,11,14I haven't actually checked the code, just skim-read it, so I may have missed some other omissions.</description><pubDate>Tue, 23 Feb 2010 12:15:48 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>[quote][b]Peter Pirker (12/9/2009)[/b][hr]Yes, I noticed - sorry to trouble you, and thank's for a great article.[/quote]Not a problem.  Thanks for the compliment.  I hope you are able to use the information provided.</description><pubDate>Wed, 09 Dec 2009 07:11:57 GMT</pubDate><dc:creator>Lynn Pettis</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>Yes, I noticed - sorry to trouble you, and thank's for a great article.</description><pubDate>Wed, 09 Dec 2009 06:57:24 GMT</pubDate><dc:creator>Peter Pirker</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>[quote][b]Peter Pirker (12/9/2009)[/b][hr]Have tried to run it (copy + paste) but get errors.What could I be doing wrong?[/quote]You may need to do some format fixing.  The code provided originally was okay, but it appears that in preping for publication that some of the spaces have been removed.</description><pubDate>Wed, 09 Dec 2009 06:56:04 GMT</pubDate><dc:creator>Lynn Pettis</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>Have tried to run it (copy + paste) but get errors.What could I be doing wrong?</description><pubDate>Wed, 09 Dec 2009 06:12:30 GMT</pubDate><dc:creator>Peter Pirker</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>Give me a moment to whipe out a teardrop of nostalgia :alien:</description><pubDate>Tue, 06 Oct 2009 03:58:08 GMT</pubDate><dc:creator>ALZDBA</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>[quote][b]TheSQLGuru (10/5/2009)[/b][hr]For me it was Hunt the Wumpus, hand-coded on my TRS-80 Model III circa 1979.  I think there was another one I did, something that started with a 'Z' - Zork, Zon?  BTW, that "computer" had 4K of RAM and CASSETTE TAPE DRIVE EXTERNAL STORAGE - and I was the baddest *** geek for a hundred miles (small-town NC at the time).  Oh, did I mention that my parents forked over $999 for it?!?!  Man have we come a damn long way![/quote]Wow - Zork!!!  That takes me back!Oh and 4K RAM?!  Luxury!  The VIC had 3.5K...and any moment now someone is going to pop up who had a ZX-80 with its 1K RAM and 4K total ROM.  Yep, the 80, not the 81.  The one which had to blank the screen when it wasn't completely idle :w00t:I used to love nothing more than adjusting the azimuth of my tape heads to try to get it it 'turbo load' the latest game.Yes, we have come an awfully long way.  Kids these days don't know they're born etc etc etc :-D</description><pubDate>Tue, 06 Oct 2009 03:17:49 GMT</pubDate><dc:creator>Paul White</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>I started programming in Junior High.  Not even on a "real" computer, an HP 9810 (a glorified programmable calculator) that my grandfather purchased for his medical lab.  First was just modifying existing code to not waste paper.  Then I actually started writing some original code for him based on the algorithims he provided.  He even provided test data and expected results.  He was doing it right and I wasn;t the one teaching him, he taught me.Edit:  Here is some info about the [url=http://www.hpmuseum.org/hp9810.htm][b]HP 9810[/b][/url].</description><pubDate>Mon, 05 Oct 2009 08:36:31 GMT</pubDate><dc:creator>Lynn Pettis</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>Data Error! Please rewind and try again.</description><pubDate>Mon, 05 Oct 2009 08:24:46 GMT</pubDate><dc:creator>Rob Fisk</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>For me it was Hunt the Wumpus, hand-coded on my TRS-80 Model III circa 1979.  I think there was another one I did, something that started with a 'Z' - Zork, Zon?  BTW, that "computer" had 4K of RAM and CASSETTE TAPE DRIVE EXTERNAL STORAGE - and I was the baddest *** geek for a hundred miles (small-town NC at the time).  Oh, did I mention that my parents forked over $999 for it?!?!  Man have we come a damn long way!</description><pubDate>Mon, 05 Oct 2009 08:16:20 GMT</pubDate><dc:creator>TheSQLGuru</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>Can't remember the first game I played. It would have been on a Vic20 at a friends house because we couldn't afford computers.My first introduction to anything resembling programming was at 7 or 8. Turtle Program for the BBC Micro. We had it at school and had the robotic turtle and everything. It was Ace. Mum got a BBC shortly after and I'd spend the evenings prepping scripts of complex patterns to take into school and draw with the robot.</description><pubDate>Mon, 05 Oct 2009 07:47:13 GMT</pubDate><dc:creator>Rob Fisk</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>[quote][b]laughingskeptic (10/4/2009)[/b][hr][quote][b]Jeff Moden (9/22/2009)[/b]That's nice, but let's see you use that in a join or even as a stand-alone result set.[/quote]A table valued function will cover this if you don't want the variable exposed in the current scope.[/quote]So, let's see the code to do that.</description><pubDate>Mon, 05 Oct 2009 05:42:14 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>The first game I played was BMX Simulator for the C64 I think... Or maybe it was Way of the Exploding Fist... either way, I don't really have a 'claim to fame' on that front!I did start programming when I was 6 though! :-D</description><pubDate>Mon, 05 Oct 2009 03:38:37 GMT</pubDate><dc:creator>Matt Whitfield</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>My first addiction was to the cartridge version (woot) of Galaxian on the VIC-20.  Awesome game.</description><pubDate>Sun, 04 Oct 2009 16:16:06 GMT</pubDate><dc:creator>Paul White</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>[quote][b]Matt Whitfield (10/4/2009)[/b][hr][quote][b]laughingskeptic (10/4/2009)[/b][hr]Clearly you did not understand the code.  COUNT returns one row.  My code returns the vector 0..N-1 based on the size of the target table.[/quote]I've got to say - I think it's you who did not understand the code. Firstly, it's a scalar variable, secondly the other code does exactly the same, just minus the rbar.Of course, it would be far more efficient to query sysindexes for the largest value anyway, then add maybe 5% to that number to account for the innaccuracies inherent therein.[/quote]Agreed :-)The posted code does not return a 'vector' (set?) at all, it just increments the value of @i once for every row.  That was the basis for sqllists very reasonable question.laughingskeptic, you need to be very sure that what you are posting is bullet-proof before making such bold statements.  Otherwise, you risk coming off as an arrogant twit.  :laugh:</description><pubDate>Sun, 04 Oct 2009 16:14:45 GMT</pubDate><dc:creator>Paul White</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>[quote][b]laughingskeptic (10/4/2009)[/b][hr]Clearly you did not understand the code.  COUNT returns one row.  My code returns the vector 0..N-1 based on the size of the target table.[/quote]I've got to say - I think it's you who did not understand the code. Firstly, it's a scalar variable, secondly the other code does exactly the same, just minus the rbar.Of course, it would be far more efficient to query sysindexes for the largest value anyway, then add maybe 5% to that number to account for the innaccuracies inherent therein.</description><pubDate>Sun, 04 Oct 2009 13:04:17 GMT</pubDate><dc:creator>Matt Whitfield</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>Clearly you did not understand the code.  COUNT returns one row.  My code returns the vector 0..N-1 based on the size of the target table.[quote][b]the sqlist (9/22/2009)[/b][hr][quote][b]laughingskeptic (9/22/2009)[/b][hr]One usualy does not need a tally table larger than the largest table.  In which case the following works as a generator:declare @i bigintset @i = 0select @i=@i+1 as num from largest_table[/quote]What happened to the good old count:declare @i bigintselect @i=count(*) from largest_table[/quote]</description><pubDate>Sun, 04 Oct 2009 09:54:07 GMT</pubDate><dc:creator>laughingskeptic</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>[quote][b]Jeff Moden (9/22/2009)[/b]That's nice, but let's see you use that in a join or even as a stand-alone result set.[/quote]A table valued function will cover this if you don't want the variable exposed in the current scope.</description><pubDate>Sun, 04 Oct 2009 09:48:53 GMT</pubDate><dc:creator>laughingskeptic</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>It were alien devices I tell you...all we got now is reverse engineered ;)</description><pubDate>Sat, 03 Oct 2009 17:19:28 GMT</pubDate><dc:creator>peter-757102</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>Barry, for some reason the music from "Twilight Zone" keeps running through my head now.</description><pubDate>Sat, 03 Oct 2009 13:42:21 GMT</pubDate><dc:creator>The Dixie Flatline</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>[quote][b]Lynn Pettis (10/2/2009)[/b][hr]Cool.  It was released in 1962 and ran initially on the PDP-1.  Was used by the FE's when setting up the PDP-1 as a final test before turning over the systems to the customer (if you can believe Wikipedia).  Pong didn't come out until 1972.[/quote]The weird thing is, that what I saw and played, shouldn't have been there.  As best as I can reconstruct it, it was at a penny arcade on the boardwalk in Ocean City MD, in the summer of either 1970 or 1971, when I was 12 or 13.  It was 3x as expensive as the other games and not very popular, sitting mostly unnoticed in a corner, but I couldn't take my eyes off of it.  I saw some older kids try to play it and walk away in disgust.  I used all of my spending money (75 cents, I think) to play one game.  The controls were exotic (two joyticks and some buttons) and it was over before I could really figure out what I was supposed to do (turns out it was a two-player game).  All-in-all a pretty dissapointing experience, but it was all I could think about for days.For years afterward, I puzzled over what the heck it was, though by my senior year in high school (74-75) Pong was in practically every other corner store, so I figured it was just some early computer video game that I had never heard.  By 1980, I had seen Computronics(sp?) re-packaged Spacewar, and I knew that that was the game that I had played, but not what the story behind it was.In the 80's and 90's I took advantage of the Arpanet and the Usenet groups to find out more (Byte magazine was a big help too).  But this is where it gets weird, because what I saw in 1970 shouldn't have existed, and certainly not where I saw it.  Because according to the official history, up until 1972, there were [i]no[/i] arcade units.  Indeed officially, there were only two built up until that time, both Lab Computers at MIT, and still in that area.  No arcade units would be built until supposedly 1972 as "Galaxy Game", and even then only a few units were ever built and it's not even clear if any of them ever made it into any arcades.Still, I saw what I saw and I [i]did[/i] play that thing way back in 1970.  And the features I remember obsessing over in high-school (gravity, hyperdrive, the fuzzy gray and white fixed starfield, the square looping geometry) were way to specific to be either a coincidence or something that I confabulated later.I only ever found 2 partial confirmations of what I saw, both from the Usenet groups in the late 80's and early 90's.  One a guy who said that he too remembered a video game almost exactly like Spacewars at an arcade on the eastern shore, at about the same time.  And another from someone who claimed to have some peripheral connection to the Spacewars developers/owners, etc., in Mass, who said that he thought that there may have been some Arcade units out there in the late 60's or early 70's before Galaxy Game was released.So my best guess as to what it was, is that it may have been that some prototype units were made, either by the Galaxy Game folks for test marketing, or by the original Spacewar owners for promotional purposes (apparently they tried doggedly to sell or license it to an arcade manufacturer up until the early 80's), and then distributed to high-profile sites, like that arcade on the boardwalk in Ocean City.I guess I'll never really know for sure though...  :satisfied:</description><pubDate>Sat, 03 Oct 2009 10:28:39 GMT</pubDate><dc:creator>RBarryYoung</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>[quote][b]Jeff Moden (10/2/2009)[/b][hr]Nope... not sure anymore.  The machine at work favored Lynn's method.  My machine at home favors the original method you posted above.  Unfortunately, I've changed jobs and the machine "at work" is no longer available to me to double check.[/quote]The change I made was simply to change the OVER ORDER BY to order by SELECT NULL rather than object_id.  It eliminates a full sort, which helps a great deal as you might imagine!  The very fastest method is still the heavily modified constant scan one (several CTEs and some UNION ALLs) but there's precious little in it.Summary of my feelings on the subject:1.  A tally table can be useful.  If you need one, create a real one.  I've yet to hear a good reason not to have one in model.2.  If you can't create a real one, regard the person telling you 'no' with suspicion.  :-)3.  A dynamic tally is probably only going to be appropriate for relatively small numbers of rows, say tens of thousands...?4.  You need a real tally table :-D5.  Lynn's method is cool.6.  The various refinements make very little difference for the sorts of sizes we should be talking about.7.  Did I mention that the best solution is a real table?  :w00t:[quote][b]Jeff Moden (10/2/2009)[/b][hr] Just one thing to be careful of, Paul.  I did a Billion row test in the past using the same method as above.  It caused the log file to grow to 40 gig.  I recommend a single cross join which will give a bit more than 16 million rows quite nicely.  For anything that requires more than the square of the rowcount in a given table, I do recommend one of the various permutations of Lynn's code shown in the article and the discussions.  I used Itzek's base 2 code and it caused no log growth on the Billion row test.[/quote]Switching to bulk logged before doing a select into will solve any logging issues of course.The thing that frustrates me about the system-table with row_number approach is the way the optimizer insists on adding row count spools to the plan.  The constant scan solution has something like 8 cross joins, but performs very slightly better because row count spools are not added.Producing a pure cross-join plan from system table inputs has eluded me thus far; this is a shame because I fancy it would be just as fast as the constant scan plan, but with much more compact code.  It's all a bit academic really, for all the points I mentioned before, but nevertheless, it is frustrating.  You will be pleased to hear that my attempts to produce a faster CLR-based version failed miserably :-)</description><pubDate>Sat, 03 Oct 2009 06:16:47 GMT</pubDate><dc:creator>Paul White</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>Cool.  It was released in 1962 and ran initially on the PDP-1.  Was used by the FE's when setting up the PDP-1 as a final test before turning over the systems to the customer (if you can believe Wikipedia).  Pong didn't come out until 1972.</description><pubDate>Fri, 02 Oct 2009 23:04:15 GMT</pubDate><dc:creator>Lynn Pettis</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>[quote][b]Lynn Pettis (10/2/2009)[/b][hr][quote][b]RBarryYoung (10/2/2009)[/b][hr][quote][b]Luke L (10/2/2009)[/b][hr]Jerky video?  Silly young'ins... we had similar games, 'cept when you did that type of stuff you might just maybe have seen some ascii art, but for the most part we just got the line "your skill has just advance or whatever"...Thanks for reminding me just how quickly I'm aging...-Luke.[/quote]Heh, you don't even want to know what my first video game was.  :-)[/quote]lemme guess, Pong.  ;-)[/quote]Dude, I played Spacewar in an arcade at the shore, circa 1970.</description><pubDate>Fri, 02 Oct 2009 22:35:26 GMT</pubDate><dc:creator>RBarryYoung</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>[quote][b]RBarryYoung (10/2/2009)[/b][hr][quote][b]Luke L (10/2/2009)[/b][hr][quote][b]Matt Whitfield (10/2/2009)[/b][hr]When I was at school there used to be a game called 'Betrayal at Krondor' - where you would meet people as you travelled around. They might have a certain skill, like lockpicking, and you would pay them x amount of whatever-currency-it-was-in-the-game, then you would see a [b]very jerky video[/b], after which a message box would pop up saying 'your lock picking skill has just increased 12 points' - and you'd be all like WTF - but somehow you were better at lock picking.I feel like you've just said 'your SQL skill has just increased 12 points' - and now I need to go and study that! Thank you :-D[/quote]Jerky video?  Silly young'ins... we had similar games, 'cept when you did that type of stuff you might just maybe have seen some ascii art, but for the most part we just got the line "your skill has just advance or whatever"...Thanks for reminding me just how quickly I'm aging...-Luke.[/quote]Heh, you don't even want to know what my first video game was.  :-)[/quote]lemme guess, Pong.  ;-)</description><pubDate>Fri, 02 Oct 2009 22:03:26 GMT</pubDate><dc:creator>Lynn Pettis</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>[quote][b]Luke L (10/2/2009)[/b][hr][quote][b]Matt Whitfield (10/2/2009)[/b][hr]When I was at school there used to be a game called 'Betrayal at Krondor' - where you would meet people as you travelled around. They might have a certain skill, like lockpicking, and you would pay them x amount of whatever-currency-it-was-in-the-game, then you would see a [b]very jerky video[/b], after which a message box would pop up saying 'your lock picking skill has just increased 12 points' - and you'd be all like WTF - but somehow you were better at lock picking.I feel like you've just said 'your SQL skill has just increased 12 points' - and now I need to go and study that! Thank you :-D[/quote]Jerky video?  Silly young'ins... we had similar games, 'cept when you did that type of stuff you might just maybe have seen some ascii art, but for the most part we just got the line "your skill has just advance or whatever"...Thanks for reminding me just how quickly I'm aging...-Luke.[/quote]Heh, you don't even want to know what my first video game was.  :-)</description><pubDate>Fri, 02 Oct 2009 21:39:28 GMT</pubDate><dc:creator>RBarryYoung</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>[quote][b]Lynn Pettis (10/2/2009)[/b][hr]On my dev system master.sys.all_parameters returns 6776 rows.  In the context of the particular database I tested it, sys.all_parameters, returned 6841.[/quote]That's why I try to stick the master.sys.system_columns, it's generally much more consistent (especially on my systems).</description><pubDate>Fri, 02 Oct 2009 21:29:40 GMT</pubDate><dc:creator>RBarryYoung</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>BTW... you can also use a WHERE NOT EXISTS against a Tally table and it'll be fast as well.  Just don't try the ol' outer join with a NULL detector in the WHERE clause because it will be slow.  Still, it will require a large enough Tally table to cover the range size you need where the other method I posted doesn't.</description><pubDate>Fri, 02 Oct 2009 20:03:00 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>[quote][b]Bob Hovious 24601 (10/2/2009)[/b][hr]I've had a lot of moments like that in here, Matt :-)    I'm not sure if it equates to +1 wisdom, or +1 intelligence, but one day I hope to level up.[/quote]I'll drink to that :-D</description><pubDate>Fri, 02 Oct 2009 15:51:04 GMT</pubDate><dc:creator>Matt Whitfield</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>I've had a lot of moments like that in here, Matt :-)    I'm not sure if it equates to +1 wisdom, or +1 intelligence, but one day I hope to level up.</description><pubDate>Fri, 02 Oct 2009 15:29:45 GMT</pubDate><dc:creator>The Dixie Flatline</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>[quote][b]TheSQLGuru (10/2/2009)[/b][hr]The key thing to be learned here is that optimal varies GREATLY depending on the situation!  Having many tricks up your sleeve for solving tsql problems (especially the common and/or very problematic ones) increases the probability that you will be able to provide the best solution to your problem on your (or like me your client's) system.[/quote]Absolutely spot on.</description><pubDate>Fri, 02 Oct 2009 15:11:03 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>[quote][b]Matt Whitfield (10/2/2009)[/b][hr]When I was at school there used to be a game called 'Betrayal at Krondor' - where you would meet people as you travelled around. They might have a certain skill, like lockpicking, and you would pay them x amount of whatever-currency-it-was-in-the-game, then you would see a very jerky video, after which a message box would pop up saying 'your lock picking skill has just increased 12 points' - and you'd be all like WTF - but somehow you were better at lock picking.I feel like you've just said 'your SQL skill has just increased 12 points' - and now I need to go and study that! Thank you :-D[/quote]Heh... that's why I comment the code... keeps the video from jerking around. :-P</description><pubDate>Fri, 02 Oct 2009 15:05:18 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>The key thing to be learned here is that optimal varies GREATLY depending on the situation!  Having many tricks up your sleeve for solving tsql problems (especially the common and/or very problematic ones) increases the probability that you will be able to provide the best solution to your problem on your (or like me your client's) system.</description><pubDate>Fri, 02 Oct 2009 14:48:36 GMT</pubDate><dc:creator>TheSQLGuru</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>[quote][b]TheSQLGuru (10/2/2009)[/b][hr]Jeff, try your sample code without your beloved clustered PK.  That eager index spool eats you alive.  74.5 cost and 2.6M IOs.  The real world rarely has the 'optimization limitations' you carry in your samples.  :blink:[/quote]I must admit I tried that too. I'm a bit busy to go into it fully right now, but I definitely think there's something to be learned there. I just need to figure out what it is :-D Any input gratefully received.</description><pubDate>Fri, 02 Oct 2009 14:39:19 GMT</pubDate><dc:creator>Matt Whitfield</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>Jeff, try your sample code without your beloved clustered PK.  That eager index spool eats you alive.  74.5 cost and 2.6M IOs.  The real world rarely has the 'optimization limitations' you carry in your samples.  :blink:</description><pubDate>Fri, 02 Oct 2009 14:31:31 GMT</pubDate><dc:creator>TheSQLGuru</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>Boy, the video game chatter has me realizing how long in the tooth I am getting as well!  sigh...:cool:</description><pubDate>Fri, 02 Oct 2009 14:25:51 GMT</pubDate><dc:creator>TheSQLGuru</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>[quote][b]Matt Whitfield (10/2/2009)[/b][hr]When I was at school there used to be a game called 'Betrayal at Krondor' - where you would meet people as you travelled around. They might have a certain skill, like lockpicking, and you would pay them x amount of whatever-currency-it-was-in-the-game, then you would see a [b]very jerky video[/b], after which a message box would pop up saying 'your lock picking skill has just increased 12 points' - and you'd be all like WTF - but somehow you were better at lock picking.I feel like you've just said 'your SQL skill has just increased 12 points' - and now I need to go and study that! Thank you :-D[/quote]Jerky video?  Silly young'ins... we had similar games, 'cept when you did that type of stuff you might just maybe have seen some ascii art, but for the most part we just got the line "your skill has just advance or whatever"...Thanks for reminding me just how quickly I'm aging...-Luke.</description><pubDate>Fri, 02 Oct 2009 13:22:24 GMT</pubDate><dc:creator>Luke L</dc:creator></item><item><title>RE: The Dynamic Tally or Numbers Table</title><link>http://www.sqlservercentral.com/Forums/Topic791498-1323-1.aspx</link><description>When I was at school there used to be a game called 'Betrayal at Krondor' - where you would meet people as you travelled around. They might have a certain skill, like lockpicking, and you would pay them x amount of whatever-currency-it-was-in-the-game, then you would see a very jerky video, after which a message box would pop up saying 'your lock picking skill has just increased 12 points' - and you'd be all like WTF - but somehow you were better at lock picking.I feel like you've just said 'your SQL skill has just increased 12 points' - and now I need to go and study that! Thank you :-D</description><pubDate>Fri, 02 Oct 2009 13:11:55 GMT</pubDate><dc:creator>Matt Whitfield</dc:creator></item></channel></rss>