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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 auto increment gone wild
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Yak Posting Veteran

50 Posts

Posted - 08/22/2013 :  00:28:08  Show Profile  Reply with Quote
Hi... I'm using a SQL 2008 database on a SQL 2012 hosted server. I have an autoincrement ID for locations that my members create. These go up by 1.... eg. 9400, 9401, 9402.

Tonight a member attempted to make a new location and the ID went from 9407, 9408 and JUMPED to 10408. Any subsequent creations only continue from 10408 onwards.

Any idea what happened here? 9409 to 10407 just aren't available.

Flowing Fount of Yak Knowledge

2242 Posts

Posted - 08/22/2013 :  01:17:40  Show Profile  Reply with Quote
May be you are handling exceptional cases... If the INSERT operation failed how you handled that scenario...
CREATE TABLE TestIdent (col1 int identity, col2 CHAR(1))
insert into TestIdent values('A')
insert into TestIdent values('B')
insert into TestIdent values('C')
insert into TestIdent values('AB')  -- failed to insert 
insert into TestIdent values('D')

SELECT * FROM testIdent
-- Here 4 is missing
col1	col2
1	A
2	B
3	C
5	D
DROP TABLE testIdent

CREATE TABLE TestIdent (col1 int identity, col2 CHAR(1))
DECLARE @input VARCHAR(5) = 'AB'  -- success for single character.. If size exceeds 1 then error, at that time you should rollback the operations(transaction)
insert into TestIdent SELECT @input
SELECT * FROM testIdent
DROP TABLE testIdent

Go to Top of Page

Starting Member

30 Posts

Posted - 08/22/2013 :  01:20:16  Show Profile  Reply with Quote
Someone created / inserted a bunch of records by mistake and deleted them? Someone reseeded the table? Something else?

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000