1

My table includes an ID that supposes to increment by 1 but it does increment by 2. Why would this be?

enter image description here


enter image description here

e_i_pi
  • 4,590
  • 4
  • 27
  • 45
  • Going by your screenshot I guess this is SQL Server. I will add that tag. Why does it matter that it skipped a number? – Nick.Mc Jan 20 '19 at 23:52
  • 1
    Possible duplicate of [Identity increment is jumping in SQL Server database](https://stackoverflow.com/questions/14146148/identity-increment-is-jumping-in-sql-server-database) – Nick.Mc Jan 20 '19 at 23:52
  • 1
    It might not be related to that other question - possibly more likely is failed inserts or something like that if the gap is just 2. – ZLK Jan 21 '19 at 00:09
  • 1
    Maybe someone deleted an entry...maybe you are filtering them out. – S3S Jan 21 '19 at 01:33
  • Do you have any triggers or similar that could be manipulating the data on the way in and possibly causing a second insert? – Mathew Paxinos Jan 21 '19 at 02:36
  • Thank you for all your replies. I am still new to SQL server and trying to learn building and connecting database tables. As per my understanding when I design a table with Primary Key as Identity which increments by 1, so I expect to have a sequential ID here. I inserted a few more rows and the result still seems unsatisfactory: – Marina Karshouli Jan 22 '19 at 01:06
  • Please give a [mcve]. Please [use text, not images/links, for text (including code, tables & ERDs)](https://meta.stackoverflow.com/q/285551/3404097). Please clarify via post edits, not comments. – philipxy Jan 22 '19 at 01:22
  • It's not normally a problem if you have missing numbers. There are many valid reasons that that can happen, and it could be quite difficult to work out what the reason by asking questions in the comments. I suggest that you don't get too hung up on it and continue learning. All you need to know from this is that there are valid reasons that can happen, and you should never build a database system that assume there will be no missing numbers – Nick.Mc Jan 26 '19 at 01:40

0 Answers0