Help and Support

FIX: ISNULL with ANSI_WARNINGS OFF Drops Connection On Divide By Zero

Article ID:259775
Last Review:March 14, 2006
Revision:5.0
This article was previously published under Q259775
BUG #: 57545 (SQLBUG_70)

SYMPTOMS

If you use Microsoft SQL Server 7.0 Service Pack 1 or Service Pack 2, and you use ISNULL as an expression that performs a divide by zero while the client has ANSI_WARNINGS set to OFF, the client disconnects. The errors that occur differ slightly depending on whether the client is ODBC, OLE DB or DB-Library-based. The ODBC and DB-Library errors follow.

ODBC Error:
[Microsoft][ODBC SQL Server Driver]Unknown token received from SQL Server
DB-Library Error:
DB-Library: Possible network error: Bad token from SQL Server: Datastream processing out of sync.
Net-Library error 0: (null)
DB-Library: DBPROCESS is dead or not enabled.

Back to the top

WORKAROUND

Set ANSI_WARNINGS to ON, or change the expression so that it will not encounter a divide by zero error.

Back to the top

STATUS

Microsoft has confirmed this to be a problem in SQL Server 7.0. This problem has been corrected in U.S. Service Pack 3 for Microsoft SQL Server 7.0. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
274799 (http://support.microsoft.com/kb/274799/) INF: How to Obtain Service Pack 3 for Microsoft SQL Server 7.0 and Microsoft Data Engine (MSDE) 1.0
For more information, contact your primary support provider.

Back to the top

MORE INFORMATION

For ODBC and OLE DB-based connections, ANSI_WARNINGS are set ON by default. For a DB-Library-based connection, the ANSI_WARNINGS option is set to OFF by default.

The following script demonstrates the problem:
use pubs
set ansi_warnings off
go

create table test(col1 int not null, col2 int not null)
insert test values(1,0)
go
select ISNULL(col1/col2, 0) from test
				
This script should return 0.

Back to the top


APPLIES TO
Microsoft SQL Server 7.0 Service Pack 1
Microsoft SQL Server 7.0 Service Pack 2

Back to the top

Keywords: 
kbbug kbfix kbqfe KB259775

Back to the top

Article Translations

 

Related Support Centers

Other Support Options

  • Contact Microsoft
    Phone Numbers, Support Options and Pricing, Online Help, and more.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.