Solved

How to setup scheduled table or query export from MSSQL 2005

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

758 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

18 Experts available now in Live!

Get 1:1 Help Now