0
我必须包含以下格式的XML行的表:SQL Server 2012的解析XML名称空间
<msit:message xmlns:wsa="http://URL1" xmlns:msit="http://URL2" xmlns:env="http://URL3">
<env:Body>
<ns0:parent xmlns:ns0="http://URL4">
<ns0:child>123456789</ns0:child>
...
</ns0:parent>
</env:Body>
</msit:message>`
在表名MYTABLE
,列名的数据。
我写了下面的查询:
;with xmlnamespaces('http://URL2' as msit,
'http://URL3' as env,
'http://URL1' as wsa,
'http://URL4' as ns0)
select
t2.field.value('child[1]','varchar(20)') as ban
from mytable
cross apply data.nodes('/message/Body/parent') t2(field)
返回空集,当我需要返回123456789
我在做什么错?
谢谢
工作!谢谢。 – Ben