Find a string from a TEXT field

  • Hello again!

    I'v been looking at how to work with text fields lately, as some of you sure remember.

    Last thing to resolve is to get the offset in wich a given string is positioned. Well, just the same as CHARINDEX does, but I realized it ain't reading further than 8.000 chars long.

    You can see my failed attempt at the bottom of the message.

    I appreciate any input

    TKX

     

       SET @StartPos = ( SELECT CHARINDEX(@StartTag, Code)-1 FROM tmp_AuditTriggerCustomized )

      SET @EndPos   = ( SELECT CHARINDEX(@EndTag,   Code)-1 FROM tmp_AuditTriggerCustomized ) + LEN(@EndTag)

      SET @PtrText = ( SELECT TEXTPTR(Code) FROM tmp_AuditTriggerCustomized )

      SET @Lenght  = @EndPos - @StartPos

      READTEXT tmp_AuditTriggerCustomized.Code @PtrText

                                               @StartPos

                                               @Lenght

  • I'll reply myself ........

    SET @StartPos = ( SELECT PATINDEX('%' + @StartTag + '%', Code)-1 FROM tmp_AuditTriggerCustomized )

    The % are wild cards, just like LIKE

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

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