You already have an excellent Id, AssetID. There is technically no reason for another "Id".
A) Is there any reason why you want to make your life harder than it should be?
B) Are there others (aka "users", "management", "my boss", ...) who want to make your life harder than it should be?
If the answer to A) is No: don't create another Id.
If the answer to A) is Yes: don't create another Id. Invent something else to make your life miserable.
If the answer to B) is No: don't create another Id.
If the answer to B) is Yes: Hmm, you could create a table that stores per ProjectID (eg. 'PROSPERITY') the first part of the associated AssetExtID (eg 'PROSP') and the highest number that you have already assigned (eg 2).
Like:
Code:
Table TableToAssistMeInmakingMyLifeHarder
ProjectID firstPart maxSeqNr
PROSPERITY PROSP 2
UNION III UNIII 2
Let your sp locate the record in TableToAssistMeInmakingMyLifeHarder that corresponds to the ProjectID. Get the value of maxSeqNr, increment it by 1, UPDATE that new value into TableToAssistMeInmakingMyLifeHarder and use the incremented value to generate the extra Id.
When your sp can't find a record for the given ProjectID,
1) INSERT a new record into TableToAssistMeInmakingMyLifeHarder with maxSeqNr = 1 and firstPart = LEFT(ProjectID, 5).
2) But perhaps you don't want that to happen, because "UNIII" indicates that the first part of your extra Id are not just the first 5 characters of ProjectID, but something you have to input manually. You may want to raise an error and end your transaction in this case.
A solution to this, is to extend the Project table with an extra NOT NULL column for the first part of the id.
Also make sure that your code is resilient towards two INSERTS that almost happen simultaneously, so the same value of maxSeqNr is not used more than once.
See how much fun all of this is? And knowing none of this is needed in any way ...
We can only hope that there are no others who want to make your life harder than it should be.
But if there are, be strong.