Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How can we Re-Generated sequencial user id in autogenerated column in sql. I have a database in which Emp_id is autogenerated column. I have deleted so many data so that Emp_id comes in un-sequence order i.e.
12
14
21
22
23
56...
So now i want this Emp_id comes in a numbering sequence i.e.
1
2
3
4
5
6.....
Posted
Comments
Prasad_Kulkarni 18-Apr-12 1:59am    
You have to truncate your table to re-generate series..
Mas11 18-Apr-12 2:03am    
Can you provide me a code.. Because their is 700 record in my table & i dont want to delete that.. Can it solve by simple sql query.

1 solution

Try this:
1. Add a column to your table and make its identity true as shown below:
ASM
alter table Example
add NewColumn int identity(1,1)

2. Then remove column emp_id from your table.
and
3. rename newcolumn with emp_id

Hope this works..
 
Share this answer
 
Comments
Mas11 18-Apr-12 2:22am    
but their is 700 data already filled in my table.. I hope this will sequence only a single row.
Prasad_Kulkarni 18-Apr-12 2:39am    
Yes it will..Have you tried this..

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