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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:57:51+00:00 2026-05-28T14:57:51+00:00

I am having a dilemma. I have a table with a column called ID

  • 0

I am having a dilemma. I have a table with a column called ID and it is the primary key. It is in automated increments so 1, 2, 3, and so forth and the table is 1-8.

A former programmer deleted row 7 and so now there is a gap between 6 and 8. I need to change the value of 8 to 7.

I have tried several things:

  • I can not edit ID 8 because it is an identity column

  • I have tried to query:

    set identity_insert mytable ON

then delete the row and re-add and edit the ID as other threads have recommended. However, the automated number kicked in, and now it is row 9 and I still can not edit the ID. I am not sure what I am doing wrong here. Is there a way to do this? Thanks in Advance.

  • 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-05-28T14:57:52+00:00Added an answer on May 28, 2026 at 2:57 pm

    You probably need to ask why it matters that the numbers are sequential with no gaps: SQL’s IDENTITY type isn’t really for this sort of functionality as you’re finding out.

    That said, if you do need to fill the gaps in, you’re nearly there — the other thing you need to do is reseed the identity field with a new starting number. In SQL Server this is achieved with DBCC CHECKIDENT.

    Don’t though make this a programmatic thing to fire — this should be a DBA task only when you need to clean the data up, and it would be fairly rare in practice (in ten years, I’ve only ever used it once. And that was on a dev database; it’s never been used on live environments). If you find you’re reseeding regularly then you need to rethink the behaviour of the application.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a dilemma. I have a field hashedX that is a hashed/salted value
I'm having something of a dilemma and would appreciate some input. I have this
I'm having a little bit of a dilemma. I have a very basic class
I'm having this big dilemma for my project in terms of performance. I have
I'm having a bit of an application structure design dilemma. I have created a
I have just started learning MVVM and having a dilemna. If I have a
I'm having a little dilemma with an iphone project. I'm getting some JSON data
I'm having a hard time finding the resources to solve my particular dilemma. I'd
I'm having a dilemma on whether or not to log SQL queries in production
I have a little dilemma that maybe you can help me sort out. I've

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.