Solved

how can i get the id update num from sql 2000 ?

Posted on 2006-07-05
1
231 Views
Last Modified: 2010-04-16
hi there ,

i have a DB whit an id row in it
this row are an Identity type that increment val are 1 .

if there was a data that i have been deltet from the DB
the id still remmber the last num he was
but in the first view i all geeting id=1
after update the id num returns to the last number he was befor the db delte.

i want to know the real number always
0
Comment
Question by:Tech_Men
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 23

Accepted Solution

by:
apresto earned 300 total points
ID: 17040831
This always happens, unless you insert the id's manually you cannot get around this.

Imagine you have this:

Id             field

1               icecream
2               worldcup
3               italy
4               pancake
5               blah
6               something

if you deleted worldcup and italy you would have:

1               icecream
4               pancake
5               blah
6               something

Unless you insert the ID yourself using something like this:

DECLARE @id int
SET @Id = (SELECT Max(Id) FROM Table) + 1

INSERT INTO Table (Id, field) VALUES (@Id, 'new field value' )

you cannot change the increment to reindex the lot (unless you drop the colum, and re insert it and reapply the increment )
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question