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 |
|
sp_wiz
Yak Posting Veteran
55 Posts |
Posted - 2001-08-22 : 03:58:19
|
| Pleaes can anyone tell me if it possible to rewrite this stored procedure so it does not use a cursorCREATE PROCEDURE [dbo].[sp_SendEmail] AS Declare @Address as varchar(120), @Subject as varchar(500), @Message varchar(5000), @id int, @statuscode intSet nocount onDeclare curList Cursor forSelect id, isnull(Address,'') As Address, Subject, MessageTextFrom NotifyQueue Where isnull(SendDate,'') = '' Open curListFetch Next From curList into @id, @Address, @Subject, @MessageWhile (@@FETCH_STATUS <> -1)begin print @address if @Address <> '' begin exec @StatusCode = master.dbo.xp_sendmail @recipients=@Address, @subject=@Subject, @message=@Message, @attachments='instructions.txt' endElse Begin Set @statuscode=1 End Update notifyQueue Set SendDate = GetDate(), SendStatus= @statuscodeWhere notifyqueue.id = @id FETCH NEXT From curList Into @id, @Address, @Subject, @MessageEndClose curListDeallocate curlistSet nocount offGO |
|
|
|
|
|
|
|