patindex alternative in SSIS

  • i need to implement the below code in ssis.

    declare @value nvarchar(200);

    set @value='EN 60325';

    WHILE @Value LIKE '%[^0-9]%'

    SET @Value = REPLACE(@Value, SUBSTRING(@Value, PATINDEX('%[^0-9]%', @Value), 1), '')

    select @value

    output-> 60325

    Mainly i need alternative to patindex.

    Thanks in advance!

  • There is no direct alternative for patindex in the derived column. So you can either use a script component with .NET, or stick with SQL.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • If you can use CLRs you could look at mdq.regexmatches. See this thread.

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

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

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