sql server - How to iterate through table for an sql job? -
performancereview
- prid
- reviewdate
- passed
- notes
- successstrategy
- empid
- nextreviewdate
above table working with, goal nextreviewdate check see if within 7 days of current date ( using datediff() ) , send email specified email address if condition true.
my question is, how make sql job perform task each performance review row in table. have researched , found information on cursors, or using while loops being slow , inefficient task. appreciated in final stage of development :)
if within sql server context , want send mails using sp_send_dbmail, using cursor loop through rows , call sp_send_dbmail fine. may not fastest in case won't matter much. not looking shave off milliseconds sort of process.
it lot more of hassle formulate set-based approach. involve creating dynamic sql statement have sp_send_dbmail calls in 1 batch. gain marginal.
Comments
Post a Comment