T-SQL Find char string and take all char to right of expression

前端 未结 3 1058
野性不改
野性不改 2021-01-19 10:56

How do I

Take:

RJI#\\\\\\\\Cjserver\\TrialWorks\\CaseFiles\\10000269\\Pleadings\\RJI - 10005781.doc

Find Constant expression \'\\\\Cjse

3条回答
  •  面向向阳花
    2021-01-19 11:33

    DECLARE @input NVarChar(1000) =
      'RJI#\\Cjserver\TrialWorks\CaseFiles\10000269\Pleadings\RJI - 10005781.doc',
            @match NVarChar(100) =
      '\\Cjserver';
    DECLARE @position Int = CHARINDEX(@match, @input);
    
    SELECT SUBSTRING(@input, @position, 1000);
    

    I'm just using 1000 for some arbitrarily large value. You should probably size this more appropriately to your data.

提交回复
热议问题