Auto Increment feature of SQL Server
Posted
by
Rahul Tripathi
on Stack Overflow
See other posts from Stack Overflow
or by Rahul Tripathi
Published on 2012-11-07T16:48:04Z
Indexed on
2012/11/07
17:00 UTC
Read the original article
Hit count: 308
I have created a table named as ABC. It has three columns which are as follows:-
The column number_pk
(int)
is the primary key of my table in which I have made the auto increment
feature on for that column.
Now I have deleted two rows from that table say Number_pk= 5
and Number_pk =6
.
The table which I get now is like this:-
Now if I again enter two new rows in this table with the same value I get the two new Number_pk starting from 7 and 8
i.e,
My question is that what is the logic behind this since I have deleted the two rows from the table. I know that a simple answer is because I have set the auto increment on for the primary key of my table. But I want to know is there any way that I can insert the two new entries starting from the last Number_pk without changing the design of my table?
And how the SQL Server manage this record since I have deleted the rows from the database??
© Stack Overflow or respective owner