Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SQL to extract Data from XML string stored in nvarchar column Expand / Collapse
Author
Message
Posted Thursday, March 20, 2014 3:45 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, October 17, 2014 5:38 AM
Points: 300, Visits: 236
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 ?
Post #1552922
Posted Thursday, March 20, 2014 5:36 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 9:39 AM
Points: 5,167, Visits: 12,017
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)')




Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1552955
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse