|
I need to output the results of a query to a CSV file then send to somebody on email. I would like to schedule this automatically on a SQL Server so is it possible to create tha CSV and attach it to an email to send out?
(comments are locked)
|
|
Not sure that you can do it without disk access per se. You could try and house the results in a variable as a comma delimited string and then spill that out as your email body. I realize this is a limited work around but it may suffice for your purposes.
(comments are locked)
|
|
Blackhawk has a good suggestion. But if you want it to truly be an attached file, you have to generate that file somewhere. Perhaps the sysadmin could authorize the proxy accounts for the SQL Server to write to a single directory and your job could "clean up after itself" and delete the csv file after it was sent? On the exteme side, you could also create a ram drive and then it would never need to touch the actual hard disk. But then windows treats those as drives and SQL Server would still need permissions on it, so I suspect that will not meet your intent.
(comments are locked)
|
|
Create a scheduled job that oops - just seen you have the SSIS tag on this. Sorry! Will leave this here anyway as an indication of a non-SSIS way! and just realised you stated 'without having to save it' - how can a csv file exist without it being saved???? Sorry I need to clarify my question a bit more. I want to create the CSV file without having to physically save the file somewhere because the server at work doesn't have permissions. I was hoping to be able to save it in memory then attach it to an email.
Mar 17 '10 at 02:09 PM
Ian Roke
(comments are locked)
|
|
Yes, I've done this. Create a CLR proc that sends a system.net.mail MailMessage. The MailMessage.Attatchments can take a stream for the attachment Excellent. Could you provide some example code? I've never used CLR before.
Mar 18 '10 at 04:48 AM
Ian Roke
(comments are locked)
|

