﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / SQL Server 2005 General Discussion  / how to log error in middle of the cursor records / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 21 May 2013 20:37:00 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: how to log error in middle of the cursor records</title><link>http://www.sqlservercentral.com/Forums/Topic556819-149-1.aspx</link><description>Why use a simple statement like [code]update myTable set Salary = salary + 100?[/code] when a horribly slow and bloated cursor approach will take exponentially longer to run?</description><pubDate>Fri, 27 May 2011 10:01:55 GMT</pubDate><dc:creator>Sean Lange</dc:creator></item><item><title>RE: how to log error in middle of the cursor records</title><link>http://www.sqlservercentral.com/Forums/Topic556819-149-1.aspx</link><description>[quote][b]blnbmv (8/21/2008)[/b][hr]hi members,I need help to make a cursor in a stored procedure to make it skip to the next id if that particular row has an error. and also I want to display the error number,error message and also for which record that error came in the database and record this error number,error message and also the record details into some table.I wanted only through cursor as I know the below scenario can be done through set based sql and also through Common table expressions.  But I want through cursor and also My cursor want to increase sal by 100 to each empno.  Eg: empno ename    sal      10     xxx         1000      20     yyy        2000      30     zzz         3000errortableerrorno      errormessage       empno ename      sal20            some error           20      yyy         2000If anyone can give with example it would be great.Thanks sai[/quote]Why do you think you need a cursor???</description><pubDate>Fri, 27 May 2011 07:16:57 GMT</pubDate><dc:creator>Ninja's_RGR'us</dc:creator></item><item><title>RE: how to log error in middle of the cursor records</title><link>http://www.sqlservercentral.com/Forums/Topic556819-149-1.aspx</link><description>An example of a cursor you can find in this post [url]http://www.sqlservercentral.com/articles/cursors/65136/[/url], but don't forget to read the discution for there is some discution possible wether it is a good thing to use cursor.  For the error-handling[code="sql"]-- Error-declarations --DECLARE	@MyErrNumber int,	@MyErrSeverity int,	@MyErrState int,	@MyErrLine int,	@MyErrProcedure nvarchar(128),	@MyErrMessage nvarchar(4000);SET @MyErrNumber = 0--		BEGIN TRY			-- execution (begin)			-- execution (end)		END TRY		BEGIN CATCH			SELECT  @MyErrNumber = ERROR_NUMBER(),				@MyErrSeverity = ERROR_SEVERITY(),				@MyErrState = ERROR_STATE(),				@MyErrLine = ERROR_LINE (),				@MyErrProcedure = ERROR_PROCEDURE(),				@MyErrMessage = ERROR_MESSAGE()						select   @MyErrNumber As ErrNumber				,@MyErrSeverity As ErrSeverity				,@MyErrState As ErrState				,@MyErrLine As ErrLine				,@MyErrProcedure As ErrProcedure				,@MyErrMessage As ErrMessage ;			-- close open transactions (only valid for transactions in try-block)			IF @@TRANCOUNT &amp;gt; 1 			BEGIN				ROLLBACK TRAN			END                                      -- DO something with error-values here 		END CATCH; [/code]</description><pubDate>Fri, 27 May 2011 07:16:07 GMT</pubDate><dc:creator>Jogos</dc:creator></item><item><title>how to log error in middle of the cursor records</title><link>http://www.sqlservercentral.com/Forums/Topic556819-149-1.aspx</link><description>hi members,I need help to make a cursor in a stored procedure to make it skip to the next id if that particular row has an error. and also I want to display the error number,error message and also for which record that error came in the database and record this error number,error message and also the record details into some table.I wanted only through cursor as I know the below scenario can be done through set based sql and also through Common table expressions.  But I want through cursor and also My cursor want to increase sal by 100 to each empno.  Eg: empno ename    sal      10     xxx         1000      20     yyy        2000      30     zzz         3000errortableerrorno      errormessage       empno ename      sal20            some error           20      yyy         2000If anyone can give with example it would be great.Thanks sai</description><pubDate>Thu, 21 Aug 2008 12:08:37 GMT</pubDate><dc:creator>blnbmv</dc:creator></item></channel></rss>