Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to setup scheduled table or query export from MSSQL 2005

Posted on 2012-03-26
3
Medium Priority
?
277 Views
Last Modified: 2012-03-27
Hi, I am looking for a tutorial that would show me how to setup an automatic MSSQL 2005 table and/or query export and email as csv at a specific time every day.

1. Is this possible?
2. Anyone know of tutorials for this specific example?

Thanks
0
Comment
Question by:Mark B
3 Comments
 
LVL 70

Assisted Solution

by:Scott Pletcher
Scott Pletcher earned 800 total points
ID: 37768001
1. Yes, definitely.

2. Probably in Books Online itself, if I understand your requirements correctly.
You can use "EXEC msdb.dbo.sp_send_dbmail" with the query option.  Look at the different @query* options.  You can specify a query and use ',' as the query_result_separator.
0
 
LVL 9

Accepted Solution

by:
OCDan earned 1200 total points
ID: 37768004
You can setup a scheduled job using SQL Server Agent, if you need pointers on that let me know. You can use code like this:

EXEC msdb.dbo.sp_send_dbmail
    @profile_name = 'ProfileName',
    @recipients = 'whomever@wherever.com',
    @query = 'select whatever from wherever' ,
    @subject = 'Query Output',
    @attach_query_result_as_file = 1 

Open in new window


This code shows you how to setup sp_send_dbmail if it is not already:
Email from SQL
0
 

Author Closing Comment

by:Mark B
ID: 37774724
Thank you, this pointed me in the right direction!
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

886 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