• Can you post your variables declaration?

    You might have a truncation problem. Check the following code that looks the same but has an important difference.

    DECLARE @ExtType varchar(10) = 'X',

    @PhoneNo varchar(20) = '+1 (202) 123-9876 X012',

    @intPos int

    select @intPos = charindex(@ExtType,Upper(@PhoneNo))

    SELECT @intPos

    GO

    DECLARE @ExtType varchar(10) = 'X',

    --Note the change on the variable length

    @PhoneNo varchar(10) = '+1 (202) 123-9876 X012',

    @intPos int

    select @intPos = charindex(@ExtType,Upper(@PhoneNo))

    SELECT @intPos

    GO

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2