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)')

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

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

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