Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
In My Table I Have Delete One Row from The Middle But Now I Want To Insert It At That Place Only.
In My Table There is Primary Key And It Is Autoincrement By 1
Please Help Me
Thanks In Advance
Posted

1 solution

You probably shouldn't try. You can do it by disabling the auto-increment while you do it and resetting the info, then doing the insert and putting the increment parameters back then re-enabling it, but it really isn't a good idea, because the advantage of an auto-increment is that it is all handled for you. If you do, then you had better do it in a stored procedure, because SQL is a multi-user system and if anyone tries to create a new record while you have auto-increment disabled you whole system will fall apart.

If you want to order the rows, then use your own ordering system instead of letting SQL handle it and specify where you want records - don't try to use the same system for two different and unrelated purposes.
 
Share this answer
 

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