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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:15:41+00:00 2026-06-09T23:15:41+00:00

SequenceId is an auto-incrementing identity column, but isn’t the primary key. What I want

  • 0

SequenceId is an auto-incrementing identity column, but isn’t the primary key.

What I want to happen is that when a row is updated, SequenceId is set to the next available value, e.g.:

_____________________
| SequenceId | Name |
| 1          | John |
| 2          | Jane |
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

Update John to Jack. SequenceId is set to the next available identity value.

_____________________
| SequenceId | Name |
| 3          | Jack |
| 2          | Jane |
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

Is this possible with SQL Server? If not, what would be an alternative?

  • 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-09T23:15:43+00:00Added an answer on June 9, 2026 at 11:15 pm

    I don’t think you can, at least not easily or cleanly. Why not use a ROWVERSION column? ROWVERSION columns are updated every time the row is updated to a new unique incrementing value in the database. You can create a computed column that converts it to a bigint if you want to index it. The downside is that timestamps are database-wide so you could get skipped numbers if you have multiple tables that use them.

    FIDDLE

    create table TestRowVersion (
        Id int primary key,
        Name varchar(20),
        BinaryRowVersion ROWVERSION,
        IntegerRowVersion as convert(BIGINT, BinaryRowVersion)
    )   
    
    create index IDX_TestRowVersion on TestRowVersion (IntegerRowVersion)
    
    insert into TestRowVersion (Id, Name) values (1, 'Alvin')
    insert into TestRowVersion (Id, Name) values (2, 'Betsy')
    insert into TestRowVersion (Id, Name) values (3, 'Charles')
    select * From TestRowVersion
    update TestRowVersion set Name = 'Frank' where Id = 2
    select * From TestRowVersion
    

    [EDIT] – updated to use RowVersion since Timestamp is deprecated

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

Sidebar

Related Questions

I want to add a new auto increment primary column to a existing table
I want to auto-generate a unique 8-10 character ID string that includes a checksum
I need to create a sequence and a trigger to auto-increment the primary key
Assume that in a database table there is a non-key column called RECORD_ID which
I am using a hibernate sequencegenerator to auto-generate unique values for my primary key
I want to retrieve the id of a newly inserted record with an auto
In PostgreSql, one can define a sequence and use it as the primary key
I have a Java program that auto dials phone numbers, it can generate sounds
I maintain an application that was originally written to be SQL Server-specific (using IDENTITY
Is it possible to use a DB sequence for some column that is not

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.