Click here to Skip to main content
Rate this: bad
good
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 22:27pm

1 solution

Rate this: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 406
1 Marcin Kozub 225
2 Sergey Alexandrovich Kryukov 205
3 Raul Iloc 170
4 Maciej Los 164
0 OriginalGriff 8,289
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,624
3 Maciej Los 4,989
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2014
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