Ask the Expert

How to display the XML result of 'Select For XML Explicit'

I'm using the For XML Explicit statement in a stored procedure. I would like to see the full result set, but only get a partial result set in the Query Analyzer result window. Is there an easy way to display the XML result or save it to a file so I can verify whether the resulting XML is well formed for the eventual user of this output?

    Requires Free Membership to View

The output of Select For XML Explicit can be voluminous. SQL Query analyzer doesn't do a great job of presenting the output of For XML queries. For the best results use the menu command Tools -> Options. On the Results tab change the "Maximum characters per column" to 8192. Then use the menu command Query -> Result in Text (Ctrl+T). These options give you the best XML output from Query Analyzer.

Even better than Query Analyzer's output is a utility that I wrote to allow experimentation with For XML queries as Appendix C of the book SQL Server 2000 XML Distilled. The code is in the book's download. The original version of the utility is in Visual Basic 6. I've also written a C# version of the utility, which is available on my Web site.


Do you have comments on this Ask the Expert Q&A? Let us know.

This was first published in May 2005

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: