Question about Xquery

  • Hi all

    Bellow are 3 queries that use Xquery:

    select * from HumanResources.JobCandidate

    where Resume.exist('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume";

    Resume/Name/Name.Last[.="Benson"]')=1

    go

    select * from HumanResources.JobCandidate

    where Resume.exist('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume";

    Resume/*/Name.Last[.="Benson"]')=1

    go

    select * from HumanResources.JobCandidate

    where Resume.exist('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume";

    //Name.Last[.="Benson"]')=1

    The first 2 quries work, but the thired on causes this runtime error:

    Msg 9314, Level 16, State 1, Line 3

    XQuery [HumanResources.JobCandidate.Resume.exist()]: Cannot implicitly atomize or apply 'fn:data()' to complex content elements, found type 'xs:anyType' within inferred type 'element({http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume}:Name.Last,xs:anyType) | element({http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume}:Name.Last,xs:string)'.

    Can someone explain to me why it causes this error?

    Adi

    --------------------------------------------------------------
    To know how to ask questions and increase the chances of getting asnwers:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Viewing post 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply