Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sqlhelp14
Yak Posting Veteran
55 Posts |
Posted - 2008-01-21 : 10:59:01
|
| In store procedure:The sql job should run automatically each afternoon at 5pmAn email confirmation should be sent if data successfully completed.i have idea like: SET sMail = SERVER.CREATEOBJECT("ADODB.Connection")sMail.Connectionstring = "Your Connection String"sMail.OpensMail.Execute("xp_startmail 'SEND ACCOUNT NAME'" )sMail.Execute("xp_sendmail 'TO CLIENT ADDRESS',@subject ='ANYTHING', @message ='SOMETHING' ,@width=5000")sMail.Execute("xp_stopmail")sMail.Closebut how to use it in sproc and how to run sql job automaically in sproc using manually written code-logic.do u have any idea about it??Thanks. |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2008-01-21 : 11:40:14
|
| Create a scheduled job in SQL. |
 |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-01-21 : 15:23:04
|
| Kind of confusion. Why start sql job in sp if you want to run the job at 5pm every day? |
 |
|
|
khusiie
Yak Posting Veteran
78 Posts |
Posted - 2008-01-21 : 15:27:48
|
| i know how to schedule job thru sql agent but i need code - how to create it in store procedure..if count<10 then--start here to create job daily at 5pm...so what should iwrite here??select * from table where time =5pmcan u tell me?thanks. |
 |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-01-21 : 15:31:16
|
| With msdb..sp_add_job, but why create job in sp? Sql'll create job every time you run the sp. |
 |
|
|
|
|
|