Errors that occur during SQL Server's use of cursors

Source: Internet
Author: User

The following insights are diaries that are made during the process of using cursors. I am also the first time to use, if there is something wrong, please criticize, we work together.

1.

  Msg 16951, Level 16, State 1, procedure Usp_proc, line 16th
The variable ' @myref ' cannot be used as a parameter because the cursor OUTPUT parameter must not be assigned cursors until the procedure is executed.

  The problem is that I'm calling a recursive, output cursor with a stored procedure

Create procUsp_proc (@level int@myref cursor varyingoutput) asbegin    if @level=3        begin             Set @myref=cursorLocal static for            Select *  from Table            Open @myref        End     if @level<3        begin        Declare @cur cursor        execUsp_proc2 @curOutput--Recursive        --        --do some operation on the @cur of the travel Mark        --        --using the cursor out        Close @cur  --Close Cursors        deallocate @cur --Delete Cursor        EndEnd            

The above error occurs if there is no close, deallocate processing of the output cursor.

Errors that occur during SQL Server's use of cursors

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.