Question about retrieving text between tags

  • Hello all,

    i have the following question,

    in a database field auxdata (ntext 16), i have text between brackets that i want to retrieve:

    ABCDEFGHIJK

    how can i become a string that contains "ABCDEFGHIJK"?

    Thx in advance

    Steve

  • Try

    CHARINDEX ( expression1 , expression2 [ , start_location ] )

  • hi,

    i have tried:

    SELECT (substring(auxdata,charindex('',auxdata),

    (charindex('',auxdata) - charindex('',auxdata)))

    FROM workitem

    but he gives me errors..

    i just need a return value as a string

  • Remove the first left parenthesis after SELECT.

  • SELECT substring(auxdata,

    charindex('TAGmanager_nameTAG',auxdata),

    (charindex('TAG/managerTAG',auxdata) - charindex('TAGmanager_nameTAG',auxdata)))

    FROM workitem

    where (id='53')

    This thing gives me following result:

    TAGmanager_nameTAG MR XXXX TAG/manager_nameTAG

    But what i do need is just the info between the 2 tags here above

    Thx

  • How about:

     

    declare

    @auxdata varchar(100)

    set

    @auxdata = 'TAGmanager_nameTAG MR XX TAG/manager_nameTAG'

    SELECT

    substring

    (@auxdata,

    charindex

    ('TAGmanager_nameTAG',@auxdata) + 18,

    (

    charindex('TAG/manager_nameTAG',@auxdata) -

    (

    charindex('TAGmanager_nameTAG',@auxdata)+ 18)))


    And then again, I might be wrong ...
    David Webb

Viewing 6 posts - 1 through 5 (of 5 total)

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