Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

identity column Expand / Collapse
Author
Message
Posted Saturday, January 3, 2009 12:26 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 6:43 PM
Points: 36,752, Visits: 31,208
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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #629327
Posted Sunday, January 4, 2009 11:14 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Thursday, June 19, 2014 6:44 PM
Points: 959, Visits: 2,884
Matt and Jeff,
The points are well taken.
Todd Fifield
Post #629483
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse