How to get string between XML element in MS SQL
Today we will see how to get only the string between XML element from MS SQL database. Sometimes we may save the data in XML format in such situation this query will be helpful.
Here I have only two element as sample, you may extend the XML based on the XML file you have in your application.
DECLARE @ProductDetails NVARCHAR(MAX), @XML XML
SET @ProductDetails='<Product>WD Hard Disk </Product><Description>1TB Passport Essential</Description>'
SET @XML = CONVERT(XML, @ProductDetails)
SELECT @XML.query('.').value('.', 'VARCHAR(1000)')
Out put of the above query will be: "WD Hard Disk 1TB Passport Essential"