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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:46:54+00:00 2026-05-11T22:46:54+00:00

I have a requirement for a program I’m working on to store job numbers

  • 0

I have a requirement for a program I’m working on to store job numbers as YY-###### with incrementing numbers starting at 000001 in each year preceded by the last two digits of the year.

The only method I’ve been able to come up with is to make a CurrentJob table and use an identity column along with the last two digits of the year and an ArchiveJob table and then combining the two via a union in a view. Then I’d have to copy the CurrentJob to ArchiveJob at the begining of the year and truncate CurrentJob.

Is there an easier way to restart the numbering (obviously not having it be an Identity column) in one table?

The client is closed on New Years so there should be no data entry at the change of the year (for a school).

  • 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-11T22:46:54+00:00Added an answer on May 11, 2026 at 10:46 pm

    An identity column is by far the fastest and most concurrent solution to generating sequential numbers inside SQL Server. There’s no need to make it too complicated though. Just have one table for generating the identity values, and reset it at the end of the year. Here’s a quick example:

    -- Sequence generating table
    create table SequenceGenerator (
        ID integer identity(1, 1) primary key clustered
    )
    
    -- Generate a new number
    insert into SequenceGenerator default values
    select @@identity
    
    -- Reset the sequence
    truncate table SequenceGenerator
    if ident_current('SequenceGenerator') <> 1 begin
        dbcc checkident('SequenceGenerator', reseed, 0)
        dbcc checkident('SequenceGenerator', reseed)
    end else begin
        dbcc checkident('SequenceGenerator', reseed, 1)
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 267k
  • Answers 267k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer #XYZBatchScheduling is a Macro library. Look in the AOT under… May 13, 2026 at 12:49 pm
  • Editorial Team
    Editorial Team added an answer Ok, I'll answer this question myself. The simple answer is:… May 13, 2026 at 12:49 pm
  • Editorial Team
    Editorial Team added an answer I just ran into this same problem today. Reading through… May 13, 2026 at 12:49 pm

Related Questions

I have a requirement for a program I'm working on to store job numbers
I have a requirement to run a server script on scheduled times entered by
I have a requirement of reading subject, sender address and message body of new
After thinking for long, I have decided to build my data app for the
I have a requirement whereby a user can specify a variable number of user-defined

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.