Click here to Skip to main content
11,709,220 members (71,249 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: SQL-Server-2008
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 20-Feb-13 21:27pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 565
1 OriginalGriff 244
2 Maciej Los 225
3 Peter Leow 219
4 Mika Wendelius 160
0 OriginalGriff 9,348
1 Sergey Alexandrovich Kryukov 8,727
2 CPallini 5,189
3 Maciej Los 4,991
4 Mika Wendelius 3,856

Advertise | Privacy | Mobile
Web03 | 2.8.150819.1 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100