Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7918225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:26:02+00:00 2026-06-03T15:26:02+00:00

In one of our apps, we read in data from a file and expand

  • 0

In one of our apps, we read in data from a file and expand it into several tables. If any part of the file is corrupt, we halt the read, and delete whatever data got inserted.

The issue, here, is that we have an auto-increment ID on one of the import tables, and when we remove a problem file, the ID continues from its post-import value, rather than its pre-import value.

In other words…

  • ID starts at 50.
  • Insert 100 records, max ID is now 150.
  • Delete 100 records, max ID is still 150.
  • Insert 50 records, ID is 200.

We’ve “lost” the range of 100 records. Is there an “auto decrement” equivalent to go with the auto increment?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T15:26:03+00:00Added an answer on June 3, 2026 at 3:26 pm

    Autonumbers shouldn’t be that meaningful to you. Their guarantee is they provide uniqueness nothing more. You can still reseed if you are using sql server DBCC CHECKIDENT.

    Checks the current identity value for the specified table and, if it is needed, changes the identity value. You can also use DBCC CHECKIDENT to manually set a new seed value for the identity column.
    

    From BOL:
    The following example forces the current identity value in the Employee table in the AdventureWorks database to a value of 30.

    USE AdventureWorks;
    GO
    DBCC CHECKIDENT ('HumanResources.Employee', RESEED, 30);
    GO
    

    I am not recommending this but just pointing it out. DBCC CHECKIDENT can throw an error if you try to reseed to a value that is already being used, in that case you’d have to have logic if you were relying upon such a task.

    I question the thought process of what makes these numbers so important? It sounds like you want one additional field called LineNumber that is incremented or decremented, etc. But even in this case you have to handle the rows that come after the deleted record. So if you have 50 rows and you delete row 25 you have to renumber anything greater then 25:

    UPDATE 
           MyTable 
    SET LineItemNumber = LineItemNumber - 1 
    WHERE 
           LineItemNumber > @LineItemNumberToBeDeleted  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

One of our apps has several thousand small data files that we're currently packaging
If we remove one of our apps from the iPhone app store what is
I'm building a config file for one of our inline apps. Its essentially a
Under AppVerifier, one of our apps blows up. I get a DMP file, but
Several of our apps use multiple databases from the example below - each in
Our database is currently at 64 Gb and one of our apps started to
A lot of users on one of our online apps complain about the app
I need to set up a payment solution within one of our Rails apps
It appears that we will have to build/deploy one of our new JBoss apps
As part of one our system's we enable a user in the backoffice to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.