You'll need to really expand your t-sql query for that. Search the knowledge base for Solution ID's S-059164 and S-014197 for insight on how to get this done.
The examples are a great guide for your task.
Great, Thanks Tim! I'll give it a look and see what I can come up with.