export data to a xml with a XSD

  • Hi, I have a XSD file and data into a table. how can i export this data into a XML file with the XSD format?

    theres no SSIS export to xml files

    thanks

  • Hello People!

    I want to know how I can get my resultset from my table to a XML-file with the structure of my XSD?

    Is it is possible with SSIS or in combination with Management Studio or .NET?

    I've already tried to use a "FOR XML" query in a variable in SSIS within the OleDBSource and then write it to a flatfile.

    THis works fine.

    ----------------------

    DECLARE @subq varchar(max)

    SET @subq = ''

    SET @subq = @subq + ( SELECT * FROM XXX FOR XML AUTO, ELEMENTS)

    SELECT @subq as XMLDATA

    ----------------------------

    But i can't figure out how to get it in the structure of the XSD.

    Can someone give me an small tutorial how to do this.

    Thanks in advance

  • I don't know of a way to get SQL Server to generate the XML in a format that conforms to your XSD automatically. What you may need to do is load the XSD as an XML schema collection, create an XML datatype which points to the schema you loaded (IE - declare @SomeXML as XML(RecentlyLoadedSchema)), and then craft your select to build XML (using the sql xml tools of FOR XML .... etc). That way SQL server will let you know if the XML generated conforms to your schema.

    Although you may get a post from one of the experts telling you how you can do what you ask directly. Im just not sure of it myself.

  • I have this same issue, did anyone ever come up with a best practises solution?

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

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