SQL to extract Data from XML string stored in nvarchar column

  • Hi, I have a column with datatype nvarchar where we are storing XML string, e.g below

    <?xml version='1.0' encoding='UTF-8'?><root available-locales="en_GB" default-locale="en_GB"><Title language-id="en_GB">Cookies</Title></root>

    now how can I pull "Cookies" from this string ?

  • declare @XML as xml

    set @XML = '<?xml version=''1.0'' encoding=''UTF-8''?><root available-locales="en_GB" default-locale="en_GB"><Title language-id="en_GB">Cookies</Title></root>'

    select @XML.value('(root/Title)[1]', 'varchar(50)')

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

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

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