SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Could not complete cursor operation 16958


Could not complete cursor operation 16958

Author
Message
Ian Scarlett
Ian Scarlett
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2201 Visits: 6858

Have a look at my earlier post about putting the set statements at the beginning of the procedure.

The bizarre solution was courtesy of Microsoft Support





Denby
Denby
SSC Veteran
SSC Veteran (268 reputation)SSC Veteran (268 reputation)SSC Veteran (268 reputation)SSC Veteran (268 reputation)SSC Veteran (268 reputation)SSC Veteran (268 reputation)SSC Veteran (268 reputation)SSC Veteran (268 reputation)

Group: General Forum Members
Points: 268 Visits: 1022
Try explicitly declaring your cursor as Local
athurgar
athurgar
SSC Veteran
SSC Veteran (247 reputation)SSC Veteran (247 reputation)SSC Veteran (247 reputation)SSC Veteran (247 reputation)SSC Veteran (247 reputation)SSC Veteran (247 reputation)SSC Veteran (247 reputation)SSC Veteran (247 reputation)

Group: General Forum Members
Points: 247 Visits: 162

Had the same error on a SQL 2005 server that had a stored proc that used a cursor that enumerated the user databases then ran a SQL command against each database.

On investigation I found it was failing on a database that had IsArithmeticAbortEnabled (this was the only difference between all of teh user databases). This was conflicting with the default behaviour of the stored procedure which was SET ARITHABORT OFF.

You may need to make sure that all of your database options align with the options for the stored procedure.





judi cantelon
judi cantelon
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 105
I had a similar problem and resolved it by moving the 'set datefirst' statement to the beginning of the script. Not sure why this worked.
rashid.hussain
rashid.hussain
Grasshopper
Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)

Group: General Forum Members
Points: 21 Visits: 338
Hey,
Just came across the same error and realised a had a 'SET DATEFIRST' after the cursor was decalred. Moved this to the top of the SP and and now it works no problems.
Had a look on the microsoft site and they suggested upgrading to SP2 for SQL 2005 so might be worth trying that too.
Hope that helps! :-)
GregoryF
GregoryF
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1184 Visits: 885
Whilst I did not have any set datefirst statements in my SP, adding it got the SP to work.

Funny thing, the SP had been working for six weeks on 25+ different servers (2005 to 2012); then, all of a sudden, this weekend it fails with the error:

Could not complete cursor operation because the set options have changed since the cursor was declared.

It's even stanger since I only use the reserved word set to set variables, so adding a set datefirst 7 makes no sense whatsoever, but it works

/* ----------------------------- */
Tochter aus Elysium, Wir betreten feuertrunken, Himmlische, dein Heiligtum!
cplommer
cplommer
Grasshopper
Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)

Group: General Forum Members
Points: 10 Visits: 28
declare calendar_cursor insensitive cursor for
select calendar, descr
from otherDatabase.otherUser.cclcald with (nolock)


Looks like your using a dynamic cursor - getting data from another database. Check the compatibility levels of the databases (Db Properties / Options). They should be the same.
TCCaines
TCCaines
Valued Member
Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)

Group: General Forum Members
Points: 71 Visits: 258
I know this is a very old topic, but I did find that the database compatibility level was causing me to experience the same error. I am running 2008 R2 and some of the databases were set to 2005. Changing them all to 2008 resolved the issue.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search