BUG: Execution of RAISERROR(@@ERROR) Causes Access Violation (302423)
The information in this article applies to:
This article was previously published under Q302423
BUG #: 101802 (sqlbug_70)
BUG #: 54124 (sqlbug_70)
SYMPTOMS
An access violation (AV) may occur when you execute this code:
RAISERROR(@@ERROR, 1,1)
A message similar to the following may be returned to the client application:
ODBC: Msg 0, Level 19, State 1
SqlDumpExceptionHandler: Process 9 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.
Connection Broken
The SQL Server error log may contain entries similar to the following: On SQL Server Service Pack 3 (7.00.961)
Short Stack Dump
0x006d0084 Module(sqlservr+2d0084) (Blob::DeleteForMaint+28b)
0x0040f487 Module(sqlservr+f487) (CMsqlExecContext::ExecuteStmts+11b)
0x0040ef35 Module(sqlservr+ef35) (CMsqlExecContext::Execute+16b)
On SQL Server Service Pack 2 (7.00.842)
Short Stack Dump
0x00720072 Module(sqlservr+320072) (BackupFileDesc::VerifyCreatability+ad)
0x004145f1 Module(sqlservr+145f1) (CMsqlExecContext::ExecuteStmts+11a)
0x0041409f Module(sqlservr+1409f) (CMsqlExecContext::Execute+16a)
On SQL Server Service Pack 1 (7.00.699) and Golden (7.00.623)
Short Stack Dump
0x00720072 Module(sqlservr+320072) (SQL_CONFIG_INFO::Dump+224)
0x00414bee Module(sqlservr+14bee) (CMsqlExecContext::ExecuteStmts+11b)
0x0041463d Module(sqlservr+1463d) (CMsqlExecContext::Execute+16b)
WORKAROUND
To work around this behavior, return the value in @@ERROR by using a return value.
For example:
Create proc ReturnErrorCode
as
declare @err int --Local variable to hold Error value.
--execute some statement
set @err = @@ERROR --This sets @@ERROR back to 0.
if @err != 0
RETURN @err
go
DECLARE @i int
exec @i = ReturnErrorCode
--Check value of @i to see if procedure was successful.
STATUS
Microsoft has confirmed this to be a problem in SQL Server 7.0.
Modification Type: | Major | Last Reviewed: | 10/16/2002 |
---|
Keywords: | kbBug kbDSupport KB302423 |
---|
|