how to select * from XML where id=1? declare @xml xml,
declare @num int
set @num = 1
set @xml = '
&lt;row&gt;
    &lt;Id&gt;1&lt;/Id&gt;
    &lt;name&gt;reza&lt;/name&gt;
&lt;/row&gt;
&lt;row&gt;
    &lt;Id&gt;2&lt;/Id&gt;
    &lt;name&gt;Masoud&lt;/name&gt;
&lt;/row&gt;
'


how to select ID = @num ??
Try this:

select 
    XRows.query('.')
FROM
    @xml.nodes('/row') AS XTbl(XRows)
WHERE
    XRows.value('(Id)[1]', 'int') = 1


This will return the entire &lt;row&gt; XML element as XML