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 8896781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:09:54+00:00 2026-06-15T00:09:54+00:00

Possible Duplicate: Reset AutoIncrement in SqlServer after Delete I’m having an annoying issue with

  • 0

Possible Duplicate:
Reset AutoIncrement in SqlServer after Delete

I’m having an annoying issue with an Identity auto-increment column value within an Sql Server 2008 database. When I delete a row from my table (or delete all rows), when I add a new entry it’s incremented from whichever value was inserted into a previous record, regardless as to whether that record still exists.

I was wondering if anyone knows how to get it so that the IDENTITY column will auto-increment from whatever the previous record that EXISTS is.

My code looks like this:

    CREATE TABLE Product
    (
            Product_Barcode INT NOT NULL PRIMARY KEY IDENTITY,
            Product_Description VARCHAR(255),
            Product_Name VARCHAR(255),
            Product_Supplier VARCHAR(255) FOREIGN KEY REFERENCES Supplier(Supplier_Name),
            Product_Size VARCHAR(255),
            Product_Weight FLOAT
    );
  • 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-15T00:09:55+00:00Added an answer on June 15, 2026 at 12:09 am

    Typically you wouldn’t want this because new and past records can share IDs. If you have referential constraints, this might cause confusion.

    The only way I know how to do it though, is by inserting using a subquery eg.

    INSERT INTO Product (Product_Barcode, Product_Description) VALUES (SELECT MAX(Product_Barcode) + 1 FROM Product, "Any description here");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: MySQL: Reorder/Reset auto increment primary key? I have an auto increment field
Possible Duplicate: Is there any way to reset :after/:before CSS rules for an element?
Possible Duplicate: Get back default properties after applying a global CSS reset I want
Possible Duplicate: How do you roll back (reset) a git repository to a particular
Possible Duplicate: Why is rake db:migrate:reset not listed in rake -T? Inside my Rails
Possible Duplicate: restart application without restarting server? How do I reset a Coldfusion Application
Possible Duplicate: How can I reset the NSUserDefaults data in the iPhone simulator? Can
Possible Duplicate: SQL exclude a column using SELECT * [except columnA] FROM tableA? I
Possible Duplicate: CSS reset - purpose of asterik within a style I was reading
Possible Duplicate: how to start counting from 1 after erase table in access ?

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.