Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Select row from non-empty node value in xml column using xml query

$
0
0

I am trying to select the rows from the table by putting the condition on the xml column. The condition like if there is date value on the node ‘Completedon’ in the xml column then select that row.

SQL
SELECT[Tasks].*FROM[TaskManager].dbo.[Tasks]WHERE([Workdetails].exist('for $x in /Root/Row where ( (empty(xs:date($x/Completedon[1])) or ($x/Completedon[1])="") ) return $x')0)

But in this above query, it selects all the rows which has the ‘Completedon’ node as well as the row without this node.

Please help me, where did I go wrong? And please help me to correct the query..


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>