How-to create a SQL Server 2005 table structure using an XML and/or XSD file

Posted on 2007-10-17
Last Modified: 2008-09-20
I currently have an XML and XSD file (XSD autogenerated from a program like XMLSPY against the XML file) and would like to create a SQL table structure by using either file. I have attempted to import into Access but our XML file utilizes both attributes, elements and empty namespace values and simply does not import correctly. Will I have to manually create the table structures so that I can import the XML data?
Question by:drgdrg
    LVL 12

    Accepted Solution

    The schema generated by XmlSpy probably does not reference the fields of your database in each element.

    Eg, do you have something like the following?

    <xsd:element name="product" sql:relation="table_1" >
    <xsd:element name="localkey" type="xsd:string" sql:field="localkey" />
    <xsd:element name="name" type="xsd:string" sql:field="name" />

    Note the sql: prefixed attributes.

    Hopefully this gives you a start as to what you need to add to your schema.
    LVL 1

    Author Comment

    Is there some sort of automatic method / wizard?  For example, in Access 2007, it will look at the XML data - no XSD required - and build all required tables and fields.  However, it only builds for the elements, not the attributes.  

    If there some sort of functionality like this in SQL 2005 or other tools that accomplish this?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Suggested Solutions

    The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
    The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API ( has made its way into the popular lexicon of the English language.  A few years ago, …
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now