How to prevent interim identity holes in SQL Server -
is there way (using config + transaction isolation levels) ensure there no interim holes in sql server identity
column? persistent holes ok. situation trying avoid when 1 query returns hole subsequent similar query returns row not yet committed when query had been run first time.
your question 1 of isolation levels , has nothing identity. same problem applies any update/insert visibility. first query can return results had include uncommited row in 1 , 1 situation: if use dirty reads (read uncommited). if do, deserve inconsistent results you'll , deserve no help.
if want see stable results between 2 consecutive reads must have transaction encompases both reads , use serializable isolation level or, better, use row versioning based isolation level snapshot. recommendation enable snapshot , use it. see using snapshot isolation.
all need promise inserts table committed in order of identity values claim.
i hope read again , realize impossibility of request ('promise ... commit..'). you can't ask guarantee success before finished. you're asking boils down asking not allocate new identity before previous allocated 1 has committed successfully. in other words, full serialization of insert transactions.
Comments
Post a Comment