Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 autoincrement id

Author  Topic 

kiranmayi
Starting Member

4 Posts

Posted - 2009-08-06 : 09:55:23
hi
iam using sqlserver 2005
in my table i have id,name,location fields.
id is autoincrement column

for example

id name location
1 abc hyd
2 xyz gun
3 pqr viz

if i delete second record and then i insert new record the data is like this

1 abc hyd
3 pqr viz
4 kkm ban
but i want like this
1 abc hyd
2 pqr viz
3 kkm ban
how can we do?





madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-08-06 : 09:56:16
Why does gap matter?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

johnconstraint
Starting Member

23 Posts

Posted - 2009-08-06 : 10:23:39
This is exactly the expected behaviour of SQL server....the autoincrement column will keep increasing the numbers, will never asign the numbers that are deleted to new records inserted....
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-08-06 : 10:24:03
you can always use row_number() to generate a continuous running number


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -