Exporting data to Excel file

I am curious what the "best practice" is for exporting data programmaticly from SQL Server to Excel.  Is it best to do it straight from SQL Server, or should I do it with in my C# code?  My program is going to pull the data, put in the excel file, then email the file.  So I could write an SP that gets the data and puts it in the file, then have the C# code run the SP and email the file; Or I could have the code do everything, pull the data, export it & email it.

If it is considered better to have the SP do it, why and what is the best way? ROWSET functions?

April 24th, 2015 1:45pm

My first thought would be to use SSIS.  But, there is nothing wrong with doing it using C# code as well.  One thing that I try to do religiously is to access the database only through stored procedures.  So my recommendation would be to write a stored proc to retrieve the data and then use C# to do the rest of the job (i.e., storing the data to a file, and e-mailing it) if you are more comfortable with C#/.Net than SSIS.
Free Windows Admin Tool Kit Click here and download it now
April 24th, 2015 1:49pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics