Re: out of order identity field - sql2000
- From: "Mike C#" <xxx@xxxxxxx>
- Date: Fri, 16 Jun 2006 18:40:16 -0400
"Erland Sommarskog" <esquel@xxxxxxxxxxxxx> wrote in message
news:Xns97E4EF3786F5CYazorman@xxxxxxxxxxxx
Mike C# (xxx@xxxxxxx) writes:
I've found that it doesn't work all too often; particularly, as you
pointed out, if you are running hyperthreading, multiple processors, or
have multiple programs updating the table simultaneously. In that third
situation IDENTITY can leave extremely large gaps in a sequence. In my
experience, the only thing an IDENTITY column can guarantee is a
different number for each row.
Gaps due to simultaneous updates is another story. If you want contiguous
numbers, you should not use IDENTITY for your real tables. (You can
still generate ids with help of a temp table with an IDENTITY column.)
So we agree on gaps.
To be honest, I don't think the INSERT statement guarantees the order in
which the rows will be inserted,
Correct.
And insert statement order guarantees.
which is a large part of the OP's problem in this situation.
I hope it isn't! What should matter is in which order the IDENTITY values
are generated. And that is what is guaranteed, at least in SQL 2005.
But this is a SQL 2000 problem. If this is supposed to be guaranteed in SQL
2000 as well, then there's apparently a hot fix needed for the OP's problem.
BTW - I didn't think about it last night, but with the SELECT INTO
statement (instead of INSERT) you might be able to use the IDENTITY()
function to assign values in the order you require.
No! I pointed this out in my post, but I say it again: SELECT INTO
with the IDENTITY() function gives no guarantee about order, and is
overall more prone to botch the order.
Hence my use of the word "might", as in "I didn't try this, so I don't know
if it will produce desired results or not."
.
- References:
- out of order identity field - sql2000
- From: bevanward
- Re: out of order identity field - sql2000
- From: Erland Sommarskog
- Re: out of order identity field - sql2000
- From: Mike C#
- Re: out of order identity field - sql2000
- From: Erland Sommarskog
- out of order identity field - sql2000
- Prev by Date: Re: out of order identity field - sql2000
- Next by Date: Re: Connecting Sql Server 2005 from ASP?
- Previous by thread: Re: out of order identity field - sql2000
- Next by thread: Re: out of order identity field - sql2000
- Index(es):
Relevant Pages
|