March 30, 2016 at 3:11 am
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.
For this above requirement I wrote one query, that is
SELECT [Tasks].* FROM [TaskManager].dbo.[Tasks] WHERE ( [Work details].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..
Thank you in advance…
April 14, 2016 at 3:33 pm
Can you provide a sample table that has data that should not return rows as well as where you do want rows. Something like this:
declare @t table (id int identity(1,1), xmldata xml);
insert into @t
values ('<x>this row returns</x>'), ('<x>this row does not return</x>');
Russel Loski, MCSE Business Intelligence, Data Platform
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy