I need to build a primary key consisting of 3 sections.
- The first section is 3 letters long and must be an a followed by two digits eg "a00"
- The second section is a 3 digit unique identifier INCLUDING LEADING ZEROES, example "003"
- The third section is the year section of the date, eg "2008"
This is all separated with dashes, so a complete key would look like "a00-014-2008"
My solution is to hold three separate columns with the data for each, unformatted, then add the clustered primary key constraint and format it when I need to display it in a view. Is this a good way of going about it? I think there might be a way to make the whole key on update using a trigger but I don't know how. Also how would I concatenate and display it in a view?
Though not a homework question, this will help me academically.