• SQL/XML (vbnet)

    Author
    Topic
    #423399

    I am trying to combine two select statements into one and I am not geting any luck with it. Can someone help out?

    SELECT statement1
    SELECT
    XMLELEMENT( NAME “household”,
    XMLATTRIBUTES( h.record_id, h.system_id, h.odbid, h.date_updated, h.date_added),
    XMLELEMENT( NAME “name”,h.name),
    XMLELEMENT( NAME “hsetype”,h.hsetype)
    )
    FROM ucd.dbo.tblrawhseholds h

    SELECT statement2
    SELECT
    XMLELEMENT( NAME “member”,
    XMLATTRIBUTES (m.record_id, m.date_added, m.date_updated),
    XMLELEMENT( NAME “client_id”,m.client_id),
    XMLELEMENT( NAME “date_entered”,m.date_entered),
    XMLELEMENT( NAME “date_ended”,m.date_ended),
    XMLELEMENT( NAME “head_of_household”, m.head_of_household),
    XMLELEMENT( NAME “relationship”, m.relationship
    )
    )
    FROM ucd.dbo.tblrawhsemembers m
    INNER JOIN ucd.dbo.tblrawhseholds h
    ON h.family_id = m.family_id

    What I am trying to get is an XML document where a household will have the xml attributes record id, date_updated etc and also will have xml elements name, type and members. the element members also have some attributes and elements that I need to include in the document. I have no idea how to tweak the statement without getting any error. please help.

    Viewing 0 reply threads
    Author
    Replies
    • #968882

      What kind of data entities are tblrawhseholds and tblrawhsemembers? You say you are trying to get an XML document, but are you trying to export data into an xml format or are you trying to read data from xml documents? From your SQL, it looks like you might be working with SQL Server tables, and if so, you need ot indicate version. scratch

      • #968892

        I am trying to export data into an xml document following a predefined schema. I’ using sql2000.

        • #968939

          Where does the schema live? Normally, an xml schema is in a schema file, sor there is no point in trying to read it with SQL, which doesn’t work anyhow. Do I understand that you want to read data from the two tables and export that data to xml using the schema you have been given? What kind of document is the schema in? You need to create an XMLDataWriter to write the data to an xml file. Do you have any experience reading and writing xml?

    Viewing 0 reply threads
    Reply To: SQL/XML (vbnet)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: