question

Colin avatar image
Colin asked

SQL queries into XML files

Hi, What is the best/easiest way to format my SQL queries into XML files. The XML files need to be formatted in specific way for some flash chart components.

Colin

xmldata-warehouse
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Matt Whitfield avatar image
Matt Whitfield answered

If it's Fusion Charts you're using, I honestly found the best way was to create a small script on IIS which ran a regular query and returned the data as necessary, because a lot of the options needed to be in data elements which didn't sensibly live in the data model I was querying. I don't actually believe they'd sit sensibly in any underlying data model, so the choices were:

  • Create a charting data model which included data elements for all the configuration options

Or

  • Use some server side scripts to emit the options as needed and keep the data model clean

I went for the latter.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Gustavo avatar image
Gustavo answered

You can use the FOR Clausule to output your queries directly into XML

http://technet.microsoft.com/en-us/library/ms173812.aspx

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Grant Fritchey avatar image
Grant Fritchey answered

SQL Server can output to XML and you can customize it to your heart's content. However, it's a lot of work, requires a ton of difficult to read code and will be very hard to maintain over time. Small changes will require lots of work. I would suggest retrieving the data using whatever coding language you're using and then formatting the XML through that language. You'll have a much greater degree of flexibility doing it that way.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.