Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to setup scheduled table or query export from MSSQL 2005

Posted on 2012-03-26
3
Medium Priority
?
268 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 69

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

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…
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 video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

730 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