sql - AutoIncrement Identity Problem -


using sql server.

table1

recordno   id --------------- 2          001 3          002 4         003 .... 

recordno column identity column table1

problem

the recordno column starting 0, times starting 2. how avoid problem -- recordno column should start 1. should not start other numbers.

recordno   id --------------     1          001 2          002 3          003 .... 

need query help

the auto-incremented identity number increments whether record committed or not. looks me possibly initial insert failing or inside transaction not being committed.

the identity column type meant surrogate identifier, , it's not recommended use number else. possible build own autoincrement functionality, that's bad idea because of performance , concurrency problems.

also, possible reseed identity column 1 thusly:

dbcc checkident (table1, reseed, 1) 

edit: assume have table definition set seed set 1 , increment set 1 well.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -