469,356 Members | 2,203 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

Identity Column Values.

How we can make identity column to have a value next to the value of previous identity column row?This sequence breaks when we delete some rows.how we can maintain this sequence?
Jul 9 '07 #1
2 1165
Motoma
3,237 Expert 2GB
Please do not post questions to the Articles section of the site. I have moved your question to the appropriate forum; hopefully you will find more help there.
Jul 11 '07 #2
Infide
28
How we can make identity column to have a value next to the value of previous identity column row?This sequence breaks when we delete some rows.how we can maintain this sequence?
You could turn identity off and on but I don't recommend this. It's not maintainable.

Expand|Select|Wrap|Line Numbers
  1. set identity_insert[mydatabase.dbo] mytable on
  2.  
Now you can insert whatever identity you want as long as it's unique.

Keep in mind that sql server keeps all transactions logged. If you delete a record from a table with the ID of 50, that record actually still exists, you just don't see it. Now if you insert a totally new record with the ID of 50, you've lost the ability to use your transaction logs in any meaningful way.

Basically, unless you have a really really good reason to maintain a number sequence as your identity column, I wouldn't recommend it.
Jul 11 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

24 posts views Thread by Ilija_G | last post: by
6 posts views Thread by Who.Really.Really.Cares | last post: by
4 posts views Thread by shorti | last post: by
15 posts views Thread by gunnar.sigurjonsson | last post: by
13 posts views Thread by PinkBishop | last post: by
reply views Thread by Frank Swarbrick | last post: by
11 posts views Thread by stegze | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.