I need some help with querying XML data in SQL Server 2012. I have a database that has a table Parameters_XML with columns
id, application, parameter_nr flag, value
The parameter_nr is for eg 1 and the value for that parameter is the following:
<Root>
<Row>
<Item id="1344" flags="257">
<Row>
<Item id="1179" flags="257">
<Str>Gall Studio Design SRL</Str>
</Item>
<Item id="1421" flags="257">
<Str>22204869</Str>
</Item>
...........................
I need to retrieve the values for all the applications where the item is 1179 and 1421.
Eg: for the application 1 the value for the item 1179 is Gall Studio Design SRL and so on.
So far I have written the following query:
SELECT
CAST(x.Value AS XML).value('(/Root/Row/Item[@id="1344"/Row/Item[@id="1179"])[1]', 'nvarchar(100)')
FROM
Parameters_Xml x
WHERE
parameter_nr = 1
But I get the following error:
XQuery [value()]: Syntax error near ')', expected ']'.
Please help me with the valid path for the items required.