Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

Symptoms

Assume that you create a stored procedure that uses a cursor on a table variable in Microsoft SQL Server 2012 or SQL Server 2014. Additionally, the stored procedure updates the table by using a WHERE CURRENT OF statement together with the cursor.

For example, your stored procedure may resemble the following:

CREATE PROCEDURE dbo.usp_TestSP AS 

BEGIN

DECLARE @TableVar TABLE (SomeInt INT NULL)
INSERT @TableVar VALUES (NULL)

DECLARE @curInt INT, @newInt INT
SET @newInt = 1

DECLARE ccc CURSOR LOCAL FOR
SELECT SomeInt FROM @TableVar WHERE SomeInt IS NULL

OPEN ccc

FETCH NEXT FROM ccc INTO @curInt
UPDATE @TableVar SET SomeInt = @newInt
WHERE CURRENT OF ccc
CLOSE ccc

SELECT * FROM @TableVar
END


When you execute your stored procedure by using the sp_refreshsqlmodule system stored procedure, an access violation may occur, and you may receive error messages that resemble the following:

Msg 596, Level 21, State 1Cannot continue the execution because the session is in the kill state.Msg 0, Level 20, State 0A severe error occurred on the current command. The results, if any, should be discarded.


In this situation, errors that resemble the following are also written to the SQL Server error logs:

date time.730 spid51 SqlDumpExceptionHandler: Process 51 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.
date time.730 spid51 * *******************************************************************************
date time.730 spid51 *
date time.730 spid51 * BEGIN STACK DUMP:
date time.730 spid51 * date time spid 51
date time.730 spid51 *
date time.730 spid51 *
date time.730 spid51 * Exception Address = 00007FFC270236D5 Module(sqllang+00000000005036D5)
date time.730 spid51 * Exception Code = c0000005 EXCEPTION_ACCESS_VIOLATION
date time.730 spid51 * Access Violation occurred reading address 0000006F00620074
date time.730 spid51 * Input Buffer 136 bytes -
date time.730 spid51 * EXECUTE sp_refreshsqlmodule N'[dbo].[usp_TestSP]'
date time.730 spid51 *
date time.730 spid51 *


Resolution

Cumulative update information

This issue is fixed in the following updates:


Each new cumulative update for SQL Server contains all the hotfixes and all the security fixes that were included with the previous cumulative update. Check out the latest cumulative updates for SQL Server:


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

References

Learn about the terminology that Microsoft uses to describe software updates.

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×