Solved

How to setup scheduled table or query export from MSSQL 2005

Posted on 2012-03-26
3
257 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 69

Assisted Solution

by:Scott Pletcher
Scott Pletcher earned 200 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 300 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

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…
When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

831 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