【发布时间】:2022-10-17 09:39:05
【问题描述】:
我有一个数据类型为XML 的表。我想通过读取那个 XML 列来获取数据。
这是存储在该列中的 XML:
<BizMsg xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:asx:xsd:xasx.802.001.04 ASX_AU_CHS_comm_802_001_04_xasx_802_001_04.xsd">
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:sese.023.001.07">
<SctiesSttlmTxInstr>
<TxId>
01114|0045852600
</TxId>
</SctiesSttlmTxInstr>
</Document>
</BizMsg>
我想在<TxId> 标签中获取价值。
我尝试运行此查询,但没有得到任何结果:
DECLARE @myDoc XML
SET @myDoc = ( Select data from TableName Where Id = 56 ) // which returns XML column value from table
SELECT @myDoc.value('(/BizMsg/Document/SctiesSttlmTxInstr/TxId)[1]', 'nvarchar(max)' )
请指教 - 我做错了什么?
【问题讨论】:
-
Where Id = 56...你没有Id -
" Select data from TableName Where Id = 56 " 此查询返回存储在表中的 XML 列
-
SQL是一些触发器/事务吗?
-
不,那里没有
标签: sql-server xml