By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,934 Members | 1,476 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,934 IT Pros & Developers. It's quick & easy.

Generate Unique Serial Number

P: 1
Hello everyone,

I have a database that generates the serial Number incrementally. However it does not reset at the beginning of a New year.

Is it possible to insert a new field to my table and have it store the years and then the serial Number increments based on this new field. I would wish to retain the data I have for 2014 and Jan 2015.


Feb 3 '15 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 2.5K+
P: 3,487
There are plenty of topics concerning unique serial numbers on this forum.

Based on the information you've given, one possible method is to generate the serial number at run-time, using the current date for the year, then counting the current number of records for the current year and incrementing that value by one. This then becomes your unique serial number for each year.

To go back and update past records, you would need to determine the year to which each record applied and the order in which they were entered. Then generate a sequence of numbers which you would combine with the year for your sequence number.

Probably many ways to solve this problem, but that is one approach.
Feb 3 '15 #2

Post your reply

Sign in to post your reply or Sign up for a free account.