|
Posted by Jim C on 11/28/06 15:13
Nope, ident_current() won't work for me because it does not reserve the
next autoinc value. It just peeks at what was inserted last. The help
says it "Returns the last identity value generated for a specified
table or view in any session and any scope." I can not see how it
could reliably be used to reserve the next autoinc value in a
multi-user system because by the time you read the value, increment it,
and insert a new record another session could easily have read the same
value and inserted a row with the value you're about to insert.
The application does its own autoinc-like stuff now but fails with a
modern sql server because it relies on the old database engine's very
different locking methods. I think what I'll explore now is getting
the id source column to be read and written inside a serializable
transaction.
Erland Sommarskog wrote:
> The function ident_current() is the one you are looking for, but the value
> it returns is global to all processes, so if you call ident_current(),
> insert a row and then look at scope_identity() you may see a different
> value, if another process was at it at the same time.
Navigation:
[Reply to this message]
|