• tfifield (1/3/2009)


    Jeff,

    As I pointed out the sequence table is ugly and only works for a single insert. It should only be done when there are interactive inserts done by users. It's useless, as you pointed out, if any set based inserts are going on.

    There is a major POS system on the market that I support that uses this type of insert logic and it performs quite well. One insert per cash register per customer standing in line. There was another one where only 1 person in the company did invoicing and it worked well.

    The application in question here was adding employees. That seems to be something that would be done one employee at a time.

    Other than these types of applications I totally agree with you. It's ugly, not set based and prone to dead locks.

    Todd Fifield

    Ah... but as I said... you CAN do batch inserts with a Sequence table instead of RBAR... it's just a pain compared to the straight forward method of using an IDENTITY column.

    The other thing that I'm trying to nicely point out is that any code that uses a sequence table where you have to provide columnar inputs to a single row is really asking for trouble because now you have an even more concentrated hotspot and requires the very definition of the table to change if you add more "countries". Whether those are the cards that have been dealt to you or not, I don't want anyone to think that's even close to the right way of doing it even if a POS 3rd party bit of software is involved.

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