Skip a letter in the alphabet in SQL query

Hi I was asked to come up with code to convert letters of the alphabet to months of the year which I did no problem. But then they  came back to me and said I needed to skip the letter "I"  in the process. I am stumped. If anyone can help I would sure appreciate it.

Data is 7115A12345. "A" is the month in this serial number that we want to convert to the month number but we need to skip "I" in the process

(ASCII(SUBSTRING(serial_number,5,1))- ASCII('A') + 1)  as [MONTH]
jnordengAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott PletcherSenior DBACommented:
CHARINDEX(SUBSTRING(serial_number,5,1), 'ABCDEFGHJKLM') AS [MONTH]
Rich WeisslerProfessional Troublemaker^h^h^h^h^hshooterCommented:
CASE
   WHEN ASCII(SUBSTRING(serial_number,5,1)) < 73 THEN (ASCII(SUBSTRING(serial_number,5,1))- ASCII('A') + 1)
   WHEN ASCII(SUBSTRING(serial_number,5,1)) =73 THEN --appropriate Error response
   ELSE (ASCII(SUBSTRING(serial_number,5,1))- ASCII('A') )
END as [MONTH]

Open in new window


This makes H=August, J=September, etc... 'I' is skipped.
You can skip the =73 case if you like... I'd included it in my testing so I could see that something happened to 'I'.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.