Click here to Skip to main content
15,893,722 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I create 30 rows and I removed it and when I create another row it take the number 31 it must
be 1
please help me
Posted

You need to reseed your identity column.
DBCC CHECKIDENT('myTable', RESEED, 0) should do the trick.
 
Share this answer
 
Comments
M-osab 1-Aug-14 10:26am    
Where I should whrite this line ?
1.The auto-increment fields from database tables are made to generate unique ID each time a you record is added, and when one or more records are deleted the IDs used for deleted records cannot be reused for adding new records. But this is the normal behavior for these auto-increment fields.

2.In your case if you have deleted all records and you want to restart the identity from 1, the solution is to reseed its value to start from 1 like is indicated in the 1st solution above.
For more details about this you could read the next MDSN link.[^]
 
Share this answer
 
v2

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