0
我在数据库表中存储了以下xml。在sql查询中提取xml元素
我想从xml中提取Productid,我一直不成功。 你能告诉我为了使查询工作需要做什么改变吗?
XML:
DECLARE @Response VARCHAR(MAX) = '<Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ProductId xsi:type="xsd:long" xmlns="http://nn.service.eservice_v1">30061</ProductId>
</Response>'
SQL查询:
select
CONVERT(XML,CONVERT(NVARCHAR(max),@Response)).value('(/Response/ProductId)[1]','nvarchar(500)') as ProviderId