• Hi David,

    Thanks for your contribution. I am sure there is someone who may find this sproc very helpful. On the other hand, I shiver whenever I see a sproc with SQL string params with programming logic in it. This type of code, imho, does not belong in a sproc. Having a simple query returning data to a program that in turn wraps it in some UI script would be a better approach. More secure, more efficient.

    Don't get me wrong, having working examples like this always helps. I just hope it doesn't find its way to production code.

    There should be a better/easier way to send query results through dbmail in HTML format. Until then, we are stuck with this. :crying:

    sp_send_dbmail: http://msdn.microsoft.com/en-us/library/ms190307.aspx