I have a database in SQL with a list of IDs and I want to replace IDs that have their last digit as a 4 or 5 (excluding those that end in "04", "05", "14", or "15") and replace it with 14 or 15. The problem is that the following command comes up with a duplication error:
SET ID = REPLACE(ID, *'X4', *'X14');
For example, consider the following ID data:
BOA04
SBA04
SBH4
BOH4
BOH14
BOZ4
Hence in the above data I only want to change SBH4 to SBH14 and BOH4 to BOH14 (but this is where it will be duplicated) and BOZ4 to BOZ14.
To summarise: For all IDs that are 4 characters in length, if the last digit is 4, then replace the last digit with 14, else if the last digit is 5, replace with 15.
If this entry already exists then ignore the replace.
Thanks in advance.