Character functions in ADS 17.0.12

Hi Team,

I am using ADS 17.0.12 and trying to use the Find function which its unable to locate. My requirement is that from the below string called @a

set @a="EXP_MATURITY=>20220822|RISK_COUNTRY=>US"

I want to extract US.

So I used this earlier : SELECT substring(@a,charindex("RISK_COUNTRY=>",@a)+14,2) . However it seems like its not doing anything and my guess is charindex is no longer valid. I tried to change it to find and that also didn't work.

Can I get some help with what should I use?

Thanks,

Chanda

  • Hi Chanda,

    This is working for me. You did not specify a database and version? I tested it on SQL Server 2014 and 2017.

    Thanks, Tom

    declare @a varchar(100);
    set @a='EXP_MATURITY=>20220822|RISK_COUNTRY=>US';
    SELECT substring(@a,charindex('RISK_COUNTRY=>',@a)+14,2) as risk_country;