Query within XML data field in SQL server table [closed]

yftpprvb  于 2023-11-16  发布在  SQL Server
关注(0)|答案(1)|浏览(120)

Closed. This question needs details or clarity . It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post .

Closed 2 days ago.
Improve this question

I have the following xml

How can I create a query to pull the content of the XML field into different columns like ComponentID , MEasure, Low_Limit, High_limit.

The table name is Transactions and the xml field name is transaction_data.

qnzebej0

qnzebej01#

Try it like this:

SELECT c.value('(ComponentID/text())[1]','nvarchar(max)') AS ComponentID
      ,c.value('(Type/text())[1]','nvarchar(max)') AS [Type]
      ,c.value('(Step/text())[1]','nvarchar(max)') AS [Step]
      --and so on...
FROM [Transactions] AS Tr
CROSS APPLY Tr.Transaction_data.nodes('/CHECKSUMObj/CHECKSUM_COMPONENT') AS A(c)

相关问题