Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-07-05
1
Medium Priority
?
232 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 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

715 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