The Basics of Using a Sequence as a Table Default

  • Comments posted to this topic are about the item The Basics of Using a Sequence as a Table Default

  • Aha! Great article, and I can immediately see a use case for having unique numbers even across different tables, where both tables get the number generated by the same sequence. e.g:

    INSERT Table1 -- generates 1
    INSERT Table1 -- generates 2

    INSERT Table2 -- generates 3

    INSERT Table1 -- generates 4
    INSERT Table1 -- generates 5

    INSERT Table2 -- generates 6
    INSERT Table2 -- generates 7
    INSERT Table2 -- generates 8
  • DaveBoltman wrote:

    Aha! Great article, and I can immediately see a use case for having unique numbers even across different tables, where both tables get the number generated by the same sequence. e.g:

    INSERT Table1 -- generates 1
    INSERT Table1 -- generates 2

    INSERT Table2 -- generates 3

    INSERT Table1 -- generates 4
    INSERT Table1 -- generates 5

    INSERT Table2 -- generates 6
    INSERT Table2 -- generates 7
    INSERT Table2 -- generates 8

    That a good demonstration but why would you need to do such a thing that wouldn't be a violation of good design?  Not trying to start a fight here.  I just can't think of a good reason to do such a thing.

     

    --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)

  • Steve, great article.  Thanks for taking the time to write it up, work out the nice simple demo's and post it all.  Well done!

    --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)

  • This was removed by the editor as SPAM

  • shamsmehra90 wrote:

    i also want some details

    Details on what?  Don't expect folks to read every post on this thread to figure out what you're talking about.  Be specific or quote the post you're identifying with!  😉

    --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)

  • This was removed by the editor as SPAM

Viewing 7 posts - 1 through 6 (of 6 total)

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