dunkin1969
asked on
*** How to Schedule, Execute, and Export a SQL statement in SQL Server 2005
Hello Experts,
I have to run a query every morning and email the results to a few people. Is there a way to automate this? I am using SQL Server Management Studio in SQL Serve 2005.
The steps are:
1- Open query
2 - execute query
3 - export results to a file (or copy/paste results to email body)
4 - email recipients
Thanks!!
I have to run a query every morning and email the results to a few people. Is there a way to automate this? I am using SQL Server Management Studio in SQL Serve 2005.
The steps are:
1- Open query
2 - execute query
3 - export results to a file (or copy/paste results to email body)
4 - email recipients
Thanks!!
Steps:
1. Right click on Sql Agent and create new job
2. Create step.
3. Paste the query in the corresponding textbox.
4. Select schedule the job and set the schedule settings
5. Click notifications and set the options. Email -> if job fails bla bla
1. Right click on Sql Agent and create new job
2. Create step.
3. Paste the query in the corresponding textbox.
4. Select schedule the job and set the schedule settings
5. Click notifications and set the options. Email -> if job fails bla bla
ASKER
Thank you rajvja. I am trying this now.
It looks like my option to email the results is grayed out.. so I am checking to see why.
It looks like my option to email the results is grayed out.. so I am checking to see why.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
SQLTriVegg,
Yes, it looks like even though SQL Server Agent can execute a SQL command, it doesn't provide a vehicle for emailing the actual results to a recipient. Liek you said, the "notifications" are referring to the job outcome... whether it was a success or failure.
Thanks for the tip.
Yes, it looks like even though SQL Server Agent can execute a SQL command, it doesn't provide a vehicle for emailing the actual results to a recipient. Liek you said, the "notifications" are referring to the job outcome... whether it was a success or failure.
Thanks for the tip.
schedule the job.