Yipes...
So even though BB4 5 is part of BB4 they may have different codes in the same database?
Could you split out the different customers' formats and codes into different lookup tables? That would make things easier. If everything in each table was formatted the same, each table could have its own query.
How to post a question to get the most help http://www.sqlservercentral.com/articles/Best+Practices/61537