Tuesday, March 27, 2012

A cursor with the name deadrow already exists.

I'm trying to track this error from the driver down:
'42000' [-1] '[Microsoft][ODBC SQL Server Driver][SQL Server]A cursor
with the name 'deadrow' already exists. ** AND ** [Microsoft][ODBC SQL
Server Driver][SQL Server]The statement has been terminated.'
[msg='SQL call failed.']."Todd" <talltodd@.hotmail.com> wrote in message
news:eda42e3f.0401090715.5e75fd6f@.posting.google.c om...
> I'm trying to track this error from the driver down:
> '42000' [-1] '[Microsoft][ODBC SQL Server Driver][SQL Server]A cursor
> with the name 'deadrow' already exists. ** AND ** [Microsoft][ODBC SQL
> Server Driver][SQL Server]The statement has been terminated.'
> [msg='SQL call failed.'].

It's not possible to say exactly what happened without more information, but
it seems that your client application has declared a cursor called deadrow
but not closed and deallocated it afterwards. If the same code is then run
again, you will get this error.

Simon|||To add to Simon's response, it's a good practice to explicitly declare
cursors as LOCAL unless you have a reason to do otherwise. This will ensure
the cursor is deallocated when it goes out of scope.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Todd" <talltodd@.hotmail.com> wrote in message
news:eda42e3f.0401090715.5e75fd6f@.posting.google.c om...
> I'm trying to track this error from the driver down:
> '42000' [-1] '[Microsoft][ODBC SQL Server Driver][SQL Server]A cursor
> with the name 'deadrow' already exists. ** AND ** [Microsoft][ODBC SQL
> Server Driver][SQL Server]The statement has been terminated.'
> [msg='SQL call failed.'].|||Dan Guzman (danguzman@.nospam-earthlink.net) writes:
> To add to Simon's response, it's a good practice to explicitly declare
> cursors as LOCAL unless you have a reason to do otherwise. This will
> ensure the cursor is deallocated when it goes out of scope.

Yeah, but then you cannot declare them as INSENSITIVE, which also is a
good practice, as that saves you from the surprises that keyset-driven
cursors can give you.

Maybe STATIC or FAST_FORWARD are the same as INSENSITIVE, but I have
never managed to grasp the cursor excesses that were added to SQL7.

Besides, INSENSITIVE is ANSI compliant, while LOCAL is not.

There is a database option to make local cursors the default, though.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!|||Actually we don't have a cursor named 'deadrow' it seems so we figure it
coming from the odbc driver for sql server.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

No comments:

Post a Comment