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:
-
Cumulative Update 13 for SQL Server 2014
-
Cumulative Update 6 for SQL Server 2014 Service Pack 1 (SP1)
-
Cumulative Update 2 for SQL Server 2012 Service Pack 3 (SP3)
-
Cumulative Update 11 for SQL Server 2012 Service Pack 2 (SP2)
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.