XSD Schema

  • I have an XML file that has data from a couple of tables.

    How do I create an XSD for this XML file?

    Is there a native way to do this with T-SQL/SQL Server 2005 or do I have to use a 3rd party product?


    Kindest Regards,

  • Yes you can...

    select XMLColumn1, XMLColumn2

    from XMLTable

    FOR XML AUTO, ELEMENTS, XMLSCHEMA ('Product')

    --Ramesh


  • Thanks for that.

    However, your code not only produced the XSD Schema but it also contains the data as well.

    Is this correct as I was under the idea that an XSD ONLY defines the structure NOT contain the data?

    Or have i got that incorrect?


    Kindest Regards,

  • Just add a WHERE clause such as 1 = 2 or TOP 0 in SELECT to return no rows...

    --Ramesh


  • Ok thanks Ramesh.


    Kindest Regards,

Viewing 5 posts - 1 through 4 (of 4 total)

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