• T-SQL is horrible at string manipulation.  Your best option is to use SQLCLR.

    You also need to better define your options, Specifically what do you want to happen when you have alphanumeric values like 'FY2017Q1' or 'FY2017Q2'?  I suspect you want '[FY2017Q1]', but your description could be interpreted to mean '[FY]2017

    1'.

    Finally, I hope that you're not planning to use these fields for dynamic SQL.  If you are set on doing that, please read up on SQL injection.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA