The Tally Table

  • Alan.B (8/17/2015)


    Jeff Moden (8/14/2015)


    Alan.B (8/14/2015)


    BobAtDBS (8/14/2015)


    I have read Jeff's article, both in the past and an hour ago. His examples aren't things we do at the TSQL level very often. I'm wondering what other uses folks have?

    Some examples include:

    * filling in missing sequence numbers & dates

    * creating sample data

    * many kinds of string manipulation

    * generating a series of numbers, dates, IP addresses

    * Splitting a string based on a delimiter or pattern (see both links in my signature line)

    * breaking a string into unigrams, bigrams, trigrams, ngrams...

    * duplicating values

    * pretty much anything you would use a loop for

    Just yesterday, I used a "micro" Tally table to create "safe" temporary passwords that won't spell English swear words or even "WTF".

    Very interesting. I've bever seen that before. It would be cool to see a sample of how you did that.

    http://thedailywtf.com/Articles/The-Automated-Curse-Generator.aspx

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • J Livingston SQL (8/18/2015)


    Alan.B (8/17/2015)


    Jeff Moden (8/14/2015)


    Alan.B (8/14/2015)


    BobAtDBS (8/14/2015)


    I have read Jeff's article, both in the past and an hour ago. His examples aren't things we do at the TSQL level very often. I'm wondering what other uses folks have?

    Some examples include:

    * filling in missing sequence numbers & dates

    * creating sample data

    * many kinds of string manipulation

    * generating a series of numbers, dates, IP addresses

    * Splitting a string based on a delimiter or pattern (see both links in my signature line)

    * breaking a string into unigrams, bigrams, trigrams, ngrams...

    * duplicating values

    * pretty much anything you would use a loop for

    Just yesterday, I used a "micro" Tally table to create "safe" temporary passwords that won't spell English swear words or even "WTF".

    Very interesting. I've bever seen that before. It would be cool to see a sample of how you did that.

    http://thedailywtf.com/Articles/The-Automated-Curse-Generator.aspx

    Heh... beautiful article and absolutely spot on. I couldn't believe that there were no filters of any sort on the function that I found at my company and changed.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Alan.B (8/17/2015)


    Jeff Moden (8/14/2015)


    Alan.B (8/14/2015)


    BobAtDBS (8/14/2015)


    I have read Jeff's article, both in the past and an hour ago. His examples aren't things we do at the TSQL level very often. I'm wondering what other uses folks have?

    Some examples include:

    * filling in missing sequence numbers & dates

    * creating sample data

    * many kinds of string manipulation

    * generating a series of numbers, dates, IP addresses

    * Splitting a string based on a delimiter or pattern (see both links in my signature line)

    * breaking a string into unigrams, bigrams, trigrams, ngrams...

    * duplicating values

    * pretty much anything you would use a loop for

    Just yesterday, I used a "micro" Tally table to create "safe" temporary passwords that won't spell English swear words or even "WTF".

    Very interesting. I've bever seen that before. It would be cool to see a sample of how you did that.

    I'll see if I can post it today. It requires 1 upper case letter, 1 lower case letter, 1 numeric digit, and 1 special symbol with a minimum of 8 characters. That's an awfully good chance of spelling something foul especially since they were always crowding the first 4 requirement in the first 4 characters leaving the last 4 characters wide open for a blue streak.

    In the process of doing the above but in a more random manner for character placement, I removed all vowels, V, W, and Y, (V looks like a U) and the digits 0 and 1 because they look like vowels. It's not perfect but its got zero chance of dropping an "F" bomb or spelling something like A55.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden (8/18/2015)


    Alan.B (8/17/2015)


    Jeff Moden (8/14/2015)


    Alan.B (8/14/2015)


    BobAtDBS (8/14/2015)


    I have read Jeff's article, both in the past and an hour ago. His examples aren't things we do at the TSQL level very often. I'm wondering what other uses folks have?

    Some examples include:

    * filling in missing sequence numbers & dates

    * creating sample data

    * many kinds of string manipulation

    * generating a series of numbers, dates, IP addresses

    * Splitting a string based on a delimiter or pattern (see both links in my signature line)

    * breaking a string into unigrams, bigrams, trigrams, ngrams...

    * duplicating values

    * pretty much anything you would use a loop for

    Just yesterday, I used a "micro" Tally table to create "safe" temporary passwords that won't spell English swear words or even "WTF".

    Very interesting. I've bever seen that before. It would be cool to see a sample of how you did that.

    I'll see if I can post it today. It requires 1 upper case letter, 1 lower case letter, 1 numeric digit, and 1 special symbol with a minimum of 8 characters. That's an awfully good chance of spelling something foul especially since they were always crowding the first 4 requirement in the first 4 characters leaving the last 4 characters wide open for a blue streak.

    In the process of doing the above but in a more random manner for character placement, I removed all vowels, V, W, and Y, (V looks like a U) and the digits 0 and 1 because they look like vowels. It's not perfect but its got zero chance of dropping an "F" bomb or spelling something like A55.

    Corporate policy should dictate that all passwords contain at least one reference to a sex act or bodily function. That way folks won't write them down on a sticky note.

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho

  • Though I have used a tally table a few times, it really is rare for me. I've heard so many people say how great they are so need to see if I can find more uses for them.

  • Eric M Russell (8/18/2015)


    Jeff Moden (8/18/2015)


    Alan.B (8/17/2015)


    Jeff Moden (8/14/2015)


    Alan.B (8/14/2015)


    BobAtDBS (8/14/2015)


    I have read Jeff's article, both in the past and an hour ago. His examples aren't things we do at the TSQL level very often. I'm wondering what other uses folks have?

    Some examples include:

    * filling in missing sequence numbers & dates

    * creating sample data

    * many kinds of string manipulation

    * generating a series of numbers, dates, IP addresses

    * Splitting a string based on a delimiter or pattern (see both links in my signature line)

    * breaking a string into unigrams, bigrams, trigrams, ngrams...

    * duplicating values

    * pretty much anything you would use a loop for

    Just yesterday, I used a "micro" Tally table to create "safe" temporary passwords that won't spell English swear words or even "WTF".

    Very interesting. I've bever seen that before. It would be cool to see a sample of how you did that.

    I'll see if I can post it today. It requires 1 upper case letter, 1 lower case letter, 1 numeric digit, and 1 special symbol with a minimum of 8 characters. That's an awfully good chance of spelling something foul especially since they were always crowding the first 4 requirement in the first 4 characters leaving the last 4 characters wide open for a blue streak.

    In the process of doing the above but in a more random manner for character placement, I removed all vowels, V, W, and Y, (V looks like a U) and the digits 0 and 1 because they look like vowels. It's not perfect but its got zero chance of dropping an "F" bomb or spelling something like A55.

    Corporate policy should dictate that all passwords contain at least one reference to a sex act or bodily function. That way folks won't write them down on a sticky note.

    You're way too optimistic. Either they'll put it under the keyboard or they will be comparing passwords.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Eric M Russell (8/18/2015)


    Jeff Moden (8/18/2015)


    Alan.B (8/17/2015)


    Jeff Moden (8/14/2015)


    Alan.B (8/14/2015)


    BobAtDBS (8/14/2015)


    I have read Jeff's article, both in the past and an hour ago. His examples aren't things we do at the TSQL level very often. I'm wondering what other uses folks have?

    Some examples include:

    * filling in missing sequence numbers & dates

    * creating sample data

    * many kinds of string manipulation

    * generating a series of numbers, dates, IP addresses

    * Splitting a string based on a delimiter or pattern (see both links in my signature line)

    * breaking a string into unigrams, bigrams, trigrams, ngrams...

    * duplicating values

    * pretty much anything you would use a loop for

    Just yesterday, I used a "micro" Tally table to create "safe" temporary passwords that won't spell English swear words or even "WTF".

    Very interesting. I've bever seen that before. It would be cool to see a sample of how you did that.

    I'll see if I can post it today. It requires 1 upper case letter, 1 lower case letter, 1 numeric digit, and 1 special symbol with a minimum of 8 characters. That's an awfully good chance of spelling something foul especially since they were always crowding the first 4 requirement in the first 4 characters leaving the last 4 characters wide open for a blue streak.

    In the process of doing the above but in a more random manner for character placement, I removed all vowels, V, W, and Y, (V looks like a U) and the digits 0 and 1 because they look like vowels. It's not perfect but its got zero chance of dropping an "F" bomb or spelling something like A55.

    Corporate policy should dictate that all passwords contain at least one reference to a sex act or bodily function. That way folks won't write them down on a sticky note.

    Now, THERE's an idea! 😀

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Iwas Bornready (8/18/2015)


    Though I have used a tally table a few times, it really is rare for me. I've heard so many people say how great they are so need to see if I can find more uses for them.

    Agreed. For most people, including myself, such opportunities to use a Tally Table or Tally Function are actually pretty rare but there's no beating them when you need them.

    The basic paradigm of how to apply such a thing has helped me a huge amount in other things, though.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden (8/18/2015)


    Iwas Bornready (8/18/2015)


    Though I have used a tally table a few times, it really is rare for me. I've heard so many people say how great they are so need to see if I can find more uses for them.

    Agreed. For most people, including myself, such opportunities to use a Tally Table or Tally Function are actually pretty rare but there's no beating them when you need them.

    The basic paradigm of how to apply such a thing has helped me a huge amount in other things, though.

    Tally tables; it's like SQL duct tape. I mean that in a good way, although it would be great if we had an ANSI standard construct in the first place.

    Like in Oracle, there is this table called DUAL which contains (1) row and (1) column called DUMMY. Where as in T-SQL we can do SELECT 1, in Oracle you must say SELECT 1 FROM DUAL, so that's what it's used for, but DUAL hardly useful for anything else.

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho

  • Eric M Russell (8/18/2015)


    Jeff Moden (8/18/2015)


    Iwas Bornready (8/18/2015)


    Though I have used a tally table a few times, it really is rare for me. I've heard so many people say how great they are so need to see if I can find more uses for them.

    Agreed. For most people, including myself, such opportunities to use a Tally Table or Tally Function are actually pretty rare but there's no beating them when you need them.

    The basic paradigm of how to apply such a thing has helped me a huge amount in other things, though.

    Tally tables; it's like SQL duct tape. I mean that in a good way, although it would be great if we had an ANSI standard construct in the first place.

    Like in Oracle, there is this table called DUAL which contains (1) row and (1) column called DUMMY. Where as in T-SQL we can do SELECT 1, in Oracle you must say SELECT 1 FROM DUAL, so that's what it's used for, but DUAL hardly useful for anything else.

    I've heard it described as the Swiss Army Knife of SQL. Just like duct tape, it sure it good for a variety of tasks. Learning how to count is fundamental; learning how to count in sets is cool. 😉

    I believe the DUAL table (at least back in Oracle 7 and 8) is because all SELECT statements must have a FROM clause. That's how it was taught to me years ago.

  • Thank the Buddha for whoever came up with the idea of a Tally table in the first place! I just love 'em (but probably everybody knows that).

    BTW. Has anybody Googled "Tally Table" recently? Try hitting the I'm Feeling Lucky button.

    For my next trick, I'll write an article "SEO for Dummies."


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • dwain.c (8/25/2015)


    Thank the Buddha for whoever came up with the idea of a Tally table in the first place! I just love 'em (but probably everybody knows that).

    In my initial research, which seems a very long time ago, I found that some fellow in the '60s had the first mention of it and he also called it a Tally Table. I used to have a link about him but it stopped working about a year after I first found it.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden (8/26/2015)


    dwain.c (8/25/2015)


    Thank the Buddha for whoever came up with the idea of a Tally table in the first place! I just love 'em (but probably everybody knows that).

    In my initial research, which seems a very long time ago, I found that some fellow in the '60s had the first mention of it and he also called it a Tally Table. I used to have a link about him but it stopped working about a year after I first found it.

    My you are up very late (or very early)!

    Or do you just not sleep?


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • dwain.c (8/25/2015)


    BTW. Has anybody Googled "Tally Table" recently? Try hitting the I'm Feeling Lucky button.

    Don't even need to hit the "Feeling Lucky" button. Your good article show up at the top of many selections.

    I think it's wonderful. The Tally Table (Numbers Table) went from a fairly unknown advanced tool to being almost a household word thanks to folks like yourself and the denizens of SQL Server Central. When you Google it now, you get thousands of hits instead of the half dozen or so just several years ago. Well done to everyone!

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden (8/26/2015)


    dwain.c (8/25/2015)


    BTW. Has anybody Googled "Tally Table" recently? Try hitting the I'm Feeling Lucky button.

    Don't even need to hit the "Feeling Lucky" button. Your good article show up at the top of many selections.

    I think it's wonderful. The Tally Table (Numbers Table) went from a fairly unknown advanced tool to being almost a household word thanks to folks like yourself and the denizens of SQL Server Central. When you Google it now, you get thousands of hits instead of the half dozen or so just several years ago. Well done to everyone!

    Well thanks Jeff! Need to include you in there somewhere though because as I recall you corrected one of my references to when a specific Tally table alternative became available in SQL.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

Viewing 15 posts - 46 through 60 (of 87 total)

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