title: T-SQL XML - Any elements exists
body: <p>I need to find out if any xml elements exists under an element. There is a possibility of multiple elements under entity or no element. below are examples of input xml (stripped out versions for readability)</p>
  <pre><code>declare @xml xml= '&lt;entity name=&quot;User&quot; /&gt;'
  declare @xml xml= '&lt;entity name=&quot;User&quot;&gt; &lt;email&gt;s@s.com&lt;/email&gt;&lt;/entity&gt;
  declare @xml xml= '&lt;entity name=&quot;User&quot;&gt; &lt;admin&gt;1&lt;/admin&gt;&lt;/entity&gt;
  
  select IsExists = ISNULL(@xml.value('(entity/text())[1]','VARCHAR(max)'), 'N')
  </code></pre>
  <p>I am trying to use value and trying to extract text out. but it doesn't seems to work. Any help or suggestion.</p>