Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

How best to send table results in an email?

$
0
0

Hi All,

We use SSIS and SQL 2012 for our data warehouse and ETL system.  Most of our SSIS packages include email tasks to let somebody know a process has completed.  I want those emails to include a very small table of any notable data.  (For example, we have validation queries that execute automatically and any with the "result" column = FAIL need to be in this email.) 

What's the best way to do this?  I'd like to build a repeatable process that can be used for any email notification.  I created a sproc that takes a query string as an input parameter and then executes it, putting the results into a temp table, then it steps through sys.columns to figure out how many columns exist, etc., etc.  It's a lot of dynamic SQL being executed and the problem is it would have to exist on every server or else the query couldn't be executed, so that was a time-consuming failure.

I considered that perhaps passing a table variable to a stored procedure would be easier.  That sproc could give the HTML back to SSIS as an output parameter.  That sproc would then only need to exist in one place and could be called from SSIS.  This seems like a viable option, but I haven't tried it yet.  Again, I think it would be a lot of dynamic SQL, not to mention difficult for less-experienced developers to maintain.

I've also considered using SQL's dbmail instead of SSIS mail tasks.  Would you suggest this method over passing a table variable to a sproc that returns HTML?  (Or possibly both together?)  I see pages online that take a query and convert it to an XML format of HTML result, but I can't seem to get this into a varchar.

Thanks,
Eric B.


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>