开发者

extracting values from typed xml in sql server

I have typed xml as one of the columns in my table (sql server 20开发者_JS百科08). I need to extract one specific value from this typed xml field. I checked across multiple sites, but only ways to extract a field from untyped xml alone is given. Help me in getting this gone.


If by typed you mean xml that has namespaces, try something like:

WITH XMLNAMESPACES ('http: //www.MySampleCompany.com' AS MY)
SELECT
   chapters.node.value('../@title', 'nvarchar(50)') AS bookTitle
FROM @data.nodes('//MY:chapter') AS chapters(node)

Vote down or comment if I misunderstand your question.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜