Click here to Skip to main content
15,609,498 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Good Day to all,

Please help me with my project, I would like to create a Custom Primary Key in my database design,
the format is [current year][current month][3 digit counter].
This goes something like this ==> 201602001. Next id should be 201602002 and so on, but here is the catch, the following month it should display ==> 201603001 then next id should be 201603002 and so on. The three digit counter should reset to 001 every month.

Is this possible?

Thank you in advance....

What I have tried:

I am new to programming and with my limited knowledge I was in the dead end. I consider creating another table to create that desired format but it would be a redundancy to the existing pk. Thank you
Posted
Updated 20-Feb-16 8:15am

1 solution

Please, read this: Custom Auto-Generated Sequences with SQL Server - SQLTeam.com[^] then change it to your needs.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900