Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2006-07-05
1
Medium Priority
?
234 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
1 Comment
 
LVL 23

Accepted Solution

by:
apresto earned 1200 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

916 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