how to extract xml value field with in sql server ( extractvalue function in mysql )

这一生的挚爱 提交于 2019-12-23 04:26:56

问题


I have to extract xml value with in sql server. Normally when I extract value field that stored in mysql I can just simply use extractvalue(data,'parent/child/node') as value

Can anyone tell me how can do this in sql server ? thanks .


回答1:


Like so:

declare @x xml = '<foo><bar>my value</bar></foo>'

select @x.value('(/foo/bar)[1]', 'varchar(30)')

The same will work for an XML column as well.



来源:https://stackoverflow.com/questions/13485110/how-to-extract-xml-value-field-with-in-sql-server-extractvalue-function-in-mys

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!