Home Forums SQL Server 2008 T-SQL (SS2K8) Trying to select XML data for one tag from an text field and isn't returning the data I need RE: Trying to select XML data for one tag from an text field and isn't returning the data I need

  • davidsalazar01 (2/11/2013)


    Hello DBA's/Developers,

    I'm trying to select XML data from one tag that is stored in an TEXT data type and can't seem to return the data I need.

    e.g. XMLProfile_TXT field and tag </DID>.

    When I try to use the following TSQL syntax below, I get '0' for every record returned:

    select charindex ('</DID>', XMLProfile_TXT) from table_name

    Everytime I select all the XML data I can see the data I need in the result set, but I don't want every tag, I just need the one noted above (e.g. </DID>).

    Can someone help? I'm sure this is an easy answer. 🙂

    Thanks!

    -Dave

    Hello and welcome to SSC,

    If you could knock up some sample data and DDL scripts, then your expected results based on the sample data provided that would be extremely useful in allowing people to help you.

    Have a read through this link --> http://www.sqlservercentral.com/articles/Best+Practices/61537/%5B/url%5D, if you're unsure how best to lay this information out. Remember that if your sample data and DDL script is readily consumable, then the volunteers for this forum are much more likely to take time out from their work to give you a hand.

    Thanks.


    --EDIT--

    This thread (http://www.sqlservercentral.com/Forums/Topic1415340-338-1.aspx) might help.


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/