How t Split last two char from varchar dataset..?

  • [font="Courier New"]Hi All,

    This is the query i have written but unable to extract last two char..

    max(CASE CHARINDEX(' ', GT.FG_DESCRIPTION, 1) WHEN 0 THEN GT.FG_DESCRIPTION

    ELSE SUBSTRING(GT.FG_DESCRIPTION, 1, CHARINDEX(' ', GT.FG_DESCRIPTION, 1) - 2) END) AS PROD_TYPE

    Output coming

    A B

    14.00-24 32 PR BKT EM937 TL 14.00-2

    700/40-22.5 16 PR BKT FLOT648 TL 700/40-22.

    30.5L-32 12 PR BKT TR137 TR 30.5L-3

    Required Output

    A B

    14.00-24 32 PR BKT EM937 TL TL

    700/40-22.5 16 PR BKT FLOT648 TL TL

    30.5L-32 12 PR BKT TR137 TR TR

    Thanks

    Bhushan[/font]

  • What does the original data look like? What is the DDL for the table?


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply