Error messages in SQL server

  • I am trying to debug an app that calls a set of nested SP's some containing cursors. I am running the SP's through Query analyzer and recieving the following error messages:

    "Server: Msg 16916, Level 16, State 1, Line 1

    A cursor with the name 'SegGrpList' does not exist.

    Server: Msg 16916, Level 16, State 1, Line 1

    A cursor with the name 'SegGrpList' does not exist.

    Server: Msg 156, Level 15, State 1, Line 1

    Incorrect syntax near the keyword 'ORDER'."

    To try to trap the error I have put print statements around the cursor in question but the error prints before the cursor has been declared, I have gone further back and placed a print statement in the SP that calls the SP with the cursor, and the error message prints before the Sp containing the cursor is called.

    Why does this happen and is ther a better way the debug the SP and Cursor?

  • I think you declare a cursor with one name, and then try to close it or fetch it with another name.

    You should check the sintaxis. Check everywhere where you write the cursor because it might be wrong. Check in the OPEN cursorname section, in the FETCH NEXT FROM, in the CLOSE and DEALLOCATE section too.

  • Yes, but this is the first time that the cursor is declared.

  • I have changed my print statements to select and that has stopped the error showing up before the debugging statement.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply