Putting It All Together

As my father-in-law is fond of saying, "Now we're all here, let's have some beer!" I'm sure there's a virtual root beer joke in there somewhere, but I digress. Now that we have all the elements, it's time to put them all together and make it work.

Creating the XML Template File

Earlier, you saw how ungainly the query syntax could be if you were to type in said syntax directly at the URL. Well, here it is again, and once the style sheet has been created, the following will work:

http://Yourserver/VirtualDir?sql=SELECT+name,+telephone1,+telephone2+,mobile,
+email,+comments+FROM+contacts+FOR+XML+auto&xsl=phone.xsl&contenttype=text/xml

In Listing 14.7—and the previous ungainly version—the code returns all the data relating ...

Get Writing Stored Procedures for Microsoft SQL Server now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.