When executed the following stored proc. it seems to be going into loop, Can you please tell me i am doing something wrong with the @bodyAll i am trying to do is concatenate few fields values and store into field emailbody which is @body.I am first filling data to cursor and then using that data and inserting into another table. I am looking at few records may 4 or 5 records each time. I am not overloading the cursor with hundreds of records.I am having problem at SET @body='ActionNo: '+@actionno+char(13)+'Description: '+@Description+char(13)I am using at two different places firsttime when it fetches firstrow from cursor and the again at fetchnext row.It is not working can you please help.CREATE PROCEDURE dbo.USP_SendEmailActions (@ModuleID int) ASDECLARE @ErrorCode intDECLARE @TransactionCountOnEntry intDECLARE @actionno nvarchar(50)DECLARE @DueDate datetimeDECLARE @Description nvarchar(150)DECLARE @body nvarchar(1000)SET NOCOUNT ONSET TRANSACTION ISOLATION LEVEL SERIALIZABLESELECT @ErrorCode = @@Error, @TransactionCountOnEntry = @@TranCountIF @ErrorCode <>0BEGIN SET NOCOUNT OFF RETURN @ErrorCodeENDDECLARE @CUR_TEMP CURSORSET @CUR_TEMP = CURSOR SCROLL FOR (Select actionno, CONVERT(varchar(10),DueDate,101) as DueDate,actiondescription from tab_ccsnetactions where modulerecordid = @ModuleID)OPEN @CUR_TEMPBEGIN TRANSACTIONFETCH FIRST FROM @CUR_TEMP INTO @actionno, @DueDate, @descriptionSET @body='ActionNo: '+@actionno+char(13)+'Description: '+@Description+char(13)WHILE @@FETCH_STATUS = 0BEGIN INSERT INTO TABLE_Emails (ActionNo, DueDate, EmailBody) VALUES (@actionno, @DueDate, @body) FETCH NEXT FROM @CUR_TEMP INTO @actionno, @DueDate, @Description SET @body='ActionNo: '+@actionno+char(13)+'Description: '+@Description+char(13)ENDSELECT @ErrorCode = @@ErrorIF @ErrorCode = ' 0'BEGIN IF @@TranCount > @TransactionCountOnEntry COMMIT TRANSACTION CLOSE @CUR_TEMP DEALLOCATE @CUR_TEMP SET NOCOUNT OFF RETURN @ErrorCodeENDELSEBEGIN CLOSE @CUR_TEMP DEALLOCATE @CUR_TEMP ROLLBACK TRANSACTION SET NOCOUNT OFF RETURN @ErrorCodeENDGO
Thank you very much for the information.