I realize that this question spans many technologies, but I am only looking for high-level contributions here.
I am currently tasked with exporting from a SQL Server proc into Excel, and then email the Excel file as attachment through SQL Agent. The SQL Agent job must be run daily.
What I have tried:
- SQL -> Excel using xp_cmdshell & bcp. This is fine but then the excel output changes non-alpha text fields to numbers. (ie. phone numbers)
- SQL OpenRowset. I can’t overcome the lack of the Jet 4.0 provider to use OpenRowset due to 64bit Win7 — from what I understand.
- SSIS. After overcoming the dynamic file name predicament, I get stuck when my data types in from SQL to Excel didn’t match up. (some Unicode to non Unicode issue)
- I can write the export process in .NET but then I do not know how to attach it to SQL Agent.
I guess my biggest question is, if you were going to address this yourself (as I am sure many of you must) which technology path should I take?
NOTE: I am almost certain I should not install Office on the Server
Thanks in advance.
I’d definitely use SSIS. I’d have a Data Flow task reading the stored procedure output and writing to the Excel file, then a Send Mail task to handle the emailing of the resulting spreadsheet. (I’ve cleaned up Unicode vs. non-Unicode confusion in the past using Derived Column transformations in my Data Flows.)
SQL Agent could be used to kick off the SSIS package, although I haven’t used it.