|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to run store procedure then send result to user
hi,
Here is the issue. There are 10 sql servers, server1, server2 ... server10 on each of the server i need to run a query, then send that result to me in email. What i'd like to do is create a store proc (for that query) then send the result to my email. How do i go about doing that? Do i need to create a store proc locally on each sql server? and how do I schedule it to run at a specific time, then send the result to my email. Thanks for your help. |
|
#3
|
||||
|
||||
|
I would use a dts package.
You can create different connection objects to access your different servers or you can programatically change the datasource through active-X scripting. As for e-mailing the results.... You can execute your stored proc/query and load the results into a global variable that can be e-mailed as the body of the message, or you can have the results dumped to a file and then attach the file to an e-mail. DTS Packages can all be scheduled through the Sql Server Agent or through the windows scheduler by executing a batch file. |
|
#4
|
|||
|
|||
|
What you'll find when you search Google
... will be the instruction to look up this command:
Code:
EXEC master..xp_sendmail @subject = 'subject', etc. look through books on-line for SQL server for the details of how to use it, and what permissions you'll need on the sproc to get it to run, along with how you'll need to have an account in your email system for the SQL Server for it to work properly. Hope this helps, Steve |
|
#5
|
|||
|
|||
|
Thank you very much everyone.
|
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > How to run store procedure then send result to user |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|