Click here to Skip to main content
15,904,497 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I have a table ABC and Column EmployeeId and salary.
I have set identity of Employee Id.
and have inserted values in tables as

VB
1   455454
2   45454
3   4545454
4   5656565
5   4545454


Now if I delete record at no four and insert a new record then it shows as:

1 455454
2 45454
3 4545454
5 4545454
6 56565645

but I want it as no 4
1 455454
2 45454
3 4545454
4 56565645
5 4545454

Please let me know how to do it.
Thanking You

Mohammad Wasif
Posted
Updated 18-Mar-11 0:29am
v2
Comments
Costica U 18-Mar-11 6:00am    
You meant "How to reset identity specification in sql server"?

 
Share this answer
 
If you do not want to reseed the table using CHECKIDENT, use the below script to insert the record.

INSERT INTO ABC (EmployeeId, Salary)
SELECT MAX(EmployeeId)+1
, [YourSalaryValue]
FROM ABC 
 
Share this answer
 
v3

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