I have a table with a column named Description that contains XML like:
<Parent>
<Child Target="A" Id="123456">
<SpecialCode Target="I" Value="2530138" />
</Child>
</Parent>
If I want to set a parameter called @value that represents the Value attribute in this xml,
How can I SELECT the rows from MyTable where the Description column has a SpecialCode attribute that is equal to @value ?
DECLARE @value varchar(20);
SET @value = '44555'
SELECT ....
FROM MyTable
How about:
If your XML column is in a different column, then you’ll use :
Just alias your tables, properly join them, and prepend your XML column with the appropriate table alias….