SQLTeam.com | Weblogs | Forums

Generate unique ref number based on year


#1

I want to generate a unique reference number in the database column

For the year 2016
ABC12016
ABC22016
ABC32016
ABC42016
...

The first three letters ABC and the year 2016 remain static for the current year,
but the number in between increments by 1 for every entry.

For the year 2017
ABC12017
ABC22017
ABC32017
ABC42017

When the entry is in 2017, it should have the first three letters ABC the same, year at the end
should be 2017 and the number in between should increment by 1 for every entry. The first entry should
start with 1.


#2

Post the DDL for the table please.