How to map SQL query results to a provided XSD file in SQL Server 2008 R2

Hi Experts,


I am running MS SQL SERVER 2008 R2.  I need to map my query results to a provided XSD file.  I did not create the XSD file and it does not look like the file was generated with my DB structure in mind.


1. How can I map the results of my SQL query to this XSD ?
2. Are there any Visual Tools for accomplishing this task more easily?
3. Do I need to register/import this XSD file into my DB?
4. Do I have to do anything special in my SQL query (aside from actually composing it) to get the resulting XML to validate?
5. Can anyone point me to a small understandable example of this sort of process?

Any help is much appreciated.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MurpheyApplication ConsultantCommented:
Hi EddieIT,

afaik, it's not possible to create an xml without mapping it.
Automatic mapping is no option, because te structure of Xml/xsd files are (mostly) quite complex, while sql output is flat.
To map this data, you need to import the xsd into a tool that makes it possible to create an object from the xsd an the sub structures.
Now a sql recordset can be mapped....
e.g. for an order item, it could look like:

we use for this kind of mapping XBintegrator.... (check
But i'm sure there are more tools like this...
ste5anSenior DeveloperCommented:
Just output your XML and use an appropriate XSLT stylsheet to create the desired output. This can be done in SSIS with a XML Task. E.g. XML Source - Making things easier with XSLT.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.