I have a XML column in a table with values like
<m lingua="1">
<coloriVini>
<i n="8" />
<i n="2" />
<i n="3" />
<i n="4" />
<i n="5" />
<i n="6" />
<i n="7" />
</coloriVini>
</m>
and I need to make a join with values from /m/coloriVini/i/@n with another table
with will be displayed comma separated , but this I can handle
One idea is to make a variable and store the XML, but I am asking you if I can do it easily
I've tried
SELECT [L].[nome]
, p.value('./coloriVini', 'xml')
FROM [dbo].[contatto] C
CROSS APPLY [xmlMailing].nodes('m') t(p)
LEFT JOIN [dbo].[lingua] L ON p.value('./@lingua', 'int') = L.id
I know p.value('./coloriVini', 'xml') or p.value('./coloriVini', 'nvarchar(200)') doesn't work, can you tell me what I'm doing wrong
Thanks