Return Child rows on a poorly typed column :)

  • I need to return all of the child values for linenumbers in a XML Document that is stored in a table.

    My Schema has xsd:anyType for most of the columns.

    When I run this query:

    SELECT

    line.value('(/lineNumber)', 'varchar(7)') as LineNumber

    FROM dbo.tBrokerInstructions

    CROSS APPLY XML_data.nodes('/brokerInstructions/brokerInstructionsLine') as Lines(line)

    I get "XQuery [dbo.tBrokerInstructions.xml_data.value()]: Cannot atomize/apply data() on expression that contains type 'lineNumber' within inferred type 'element(lineNumber,#anonymous) *'"

    Can I use the string function to get this to work?

    Any help?

  • I hacked a way using OPENXML. It wasn't pretty.

    If I had loaded the XML to a variable would the bad schema still have stuck?

    Thanks....

Viewing 2 posts - 1 through 1 (of 1 total)

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