Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Identity Column

Author  Topic 

Jonnyu182
Starting Member

2 Posts

Posted - 2010-04-01 : 10:27:20
Hi all,

If I try to insert a record into a table with a identify column but for what ever reason it fails does it still reserve that number..

So 1, 2, 3, 4 all go in successfully but 5 and 6 fail due to invalid data. Does then my 7th attempt use key 5 or 7?


A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station...

__________________

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-04-01 : 10:28:53
It will use 7

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-04-01 : 10:30:41
And you should not worry about gaps in your identity column.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Jonnyu182
Starting Member

2 Posts

Posted - 2010-04-01 : 10:31:08
Just what I wanted to hear. Thank You!

A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station...

__________________
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-04-01 : 12:14:34
Reason is (in case of passing interest!):

Allocate next number
(Another process can then safely allocate another "next number")
Attempt to insert into table. May succeed, may fail
...
Even if succeeds batch may subsequently ROLLBACK
Go to Top of Page
   

- Advertisement -