Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am inserting some data in send request table of my database. I have used break point and it shows that primary key has value of 1 but when i m checking it in SQL management studio there primary key value is greater than 1000 each time. please help me what is this problem and how to solve it.
I have deleted the all records from that table. there is no data it means when i m inserting the new data it should be on id 1 but its on id 1003 or 1004 .

What I have tried:

I have searched on the internet and i have used ressed table identity but its not working in asp .net mvc.
Posted
Updated 2-Oct-16 9:02am
v2
Comments
[no name] 2-Oct-16 14:53pm    
Probably because you have that column set to be auto increment.

1 solution

As pointed out by NotPolitcallyCorrect[^] you probably use an automatically incrementing identity.

First of all since this kind of key definition serves only as a unique identifier for a single row, it should not matter what the value is. 1000 is just as fine as 1, since it just identifies a row.

You will probably always have gaps in the numbering. For example if
- you add three rows in the table: 1, 2, and 3
- you delete row 2
- you now have rows 1 and 3

If you still want to reset the identity, have a look at reseeding the value with DBCC CHECKIDENT (Transact-SQL)[^]
 
Share this answer
 
Comments
Member 12771245 2-Oct-16 15:08pm    
thanks for your time. But now it automatically inserting data on number 1 :)
Karthik_Mahalingam 3-Oct-16 2:12am    
if it works, please click "accept answer" to close this post.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900