Solved

How to Generate CSV file from SQL server tables and send it by email  to recipients in an automated process

Posted on 2010-11-11
3
1,111 Views
Last Modified: 2012-05-10
I have to generate a report using two tables in SQL server 2008 and send it in CSV format to recipients.
 I have already written the query(Thats Okay) . How can I use reporting services ,SSRS to do this automatically . That is send the CSV file to email automatically everyday.
or SSIS or what other process can I use to do this and automate the whole process to go everyday.

Pls can you outline the steps very well and processes I should use.if there are little code involved too, pls let me have it.

0
Comment
Question by:marvo2010
3 Comments
 
LVL 9

Expert Comment

by:radcaesar
ID: 34109719
Use BCP
Create a folder and place the file there.
Use Database mail to send mail with attachment. Below the reference

http://blogs.msdn.com/b/sqlagent/archive/2010/11/10/sql-database-mail-send-emails-with-attachment.aspx

Use a batch file to achieve the above steps. And schedule the batch file if needed.

Note; Use SQLCMD.exe to run sql scripts inside batch file.
0
 
LVL 15

Accepted Solution

by:
AmmarR earned 500 total points
ID: 34109738
Use SSIS and create a package to export to csv and email and schedule a job to run it daily

using SSIS to export to csv
http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/DTS/Q_24002244.html

using SSIS to send email
http://www.mssqltips.com/tip.asp?tip=1731
0
 
LVL 21

Expert Comment

by:Alpesh Patel
ID: 34110039
Hi,

Export data using the "BCP" and send mail using db_sendmail SP.

else

best way to Create SSIS packages.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Earlier I wrote an article about the new lookup functions (http://www.experts-exchange.com/A_3433.html) that ship with SQL Server 2008 R2.  In this article I’m going to show you another new feature of SSRS 2008 R2, this time in the vis…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now