问题
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