Please start any new threads on our new 
    site at https://forums.sqlteam.com.  We've got lots of great SQL Server
    experts to answer whatever question you can come up with.
    
        | 
                
                    | 
                            
                                | Author | Topic |  
                                    | NeeliStarting Member
 
 
                                        1 Post | 
                                            
                                            |  Posted - 2013-10-21 : 03:06:37 
 |  
                                            | I have a column XMLRECORD of XML type in a table called ABCD. My records are<row id="100" xml:space="preserve">  <c9>400</c9>  <c10>4000</c10></row><row id="90" xml:space="preserve">  <c9>324</c9>  <c10>34</c10></row>I am trying to compare the two nodes of this XMLRECORD using the querySELECT XMLRECORD FROM ABCD WHERE XMLRECORD.exist(N'/row[c9/text() < c10/text()]') = 1When executed in SQL SERVER it displays both the records doing the ASCII compare. How to force the SQL SERVER to go for a numeric compare? |  |  
                                    | visakh16Very Important crosS Applying yaK Herder
 
 
                                    52326 Posts | 
                                        
                                          |  Posted - 2013-10-21 : 09:11:03 
 |  
                                          | cast and then do the comparison.See this illustration declare @x table( x xml)insert @xvalues('<row id="100" xml:space="preserve"><c9>400</c9><c10>4000</c10></row>'),('<row id="90" xml:space="preserve"><c9>324</c9><c10>34</c10></row>')SELECT * FROM @x WHERE x.exist('/row[c9[1] cast as xs:integer?  < c10[1] cast as xs:integer?]') = 1output-------------------------------------x-------------------------------------<row id="100" xml:space="preserve"><c9>400</c9><c10>4000</c10></row>------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |  
                                          |  |  |  
                                |  |  |  |