Solved

How to setup scheduled table or query export from MSSQL 2005

Posted on 2012-03-26
3
256 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:ScottPletcher
ScottPletcher 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Where not exists in same table 3 51
Incremental load example 2 52
how many extra RAM for SQL server is needed 22 34
SQL Agent Timeout 5 47
In this article I will describe the Backup & Restore 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.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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

15 Experts available now in Live!

Get 1:1 Help Now