FIX: CASE Using LIKE with Empty String Can Result in Access Violation or Abnormal Server Shutdown

This article was previously published under Q279293
This article has been archived. It is offered "as is" and will no longer be updated.
BUG #: 350799 (shiloh_bugs)
SYMPTOMS
A Transact-SQL SELECT statement that uses a CASE function with a LIKE comparison against an empty string can fail with an access violation (AV). In some cases, this can cause SQL Server to be shut down abnormally.
RESOLUTION
To resolve this problem, obtain the latest service pack for Microsoft SQL Server 2000. For additional information, click the following article number to view the article in theMicrosoft Knowledge Base:
290211 INF: How to Obtain the Latest SQL Server 2000 Service Pack

Hotfix

NOTE: The following hotfix was created prior to Microsoft SQL Server 2000 Service Pack 1.

The English version of this fix should have the following file attributes or later:
   Version       File name        Platform   ---------------------------------------   8.00.217      S80217i.exe      Intel				
NOTE: Due to file dependencies, the most recent hotfix or feature that contains the above files may also contain additional files.
WORKAROUND
Because the problem only occurs when using LIKE with an empty string constant value (that is, ''), use the "=" operator because LIKE and "=" produce the same results if no pattern matching characters (such as "%") exist in the expression.
STATUS
Microsoft has confirmed that this is a problem in Microsoft SQL Server 2000. This problem was first corrected in SQL Server 2000 Service Pack 1.
MORE INFORMATION
The following is an example SELECT statement that will encounter this problem:
select city  = CASE  WHEN city  like '' THEN NULL ELSE city  END,        address = CASE  WHEN address like '' THEN NULL ELSE address ENDfrom authors  				
In this case, to work around the problem, change this query to:
select city  = CASE  WHEN city = '' THEN NULL ELSE city  END,        address = CASE  WHEN address = '' THEN NULL ELSE address ENDfrom authors				
terminate terminates terminated
Properties

Article ID: 279293 - Last Review: 12/05/2015 22:45:32 - Revision: 3.1

  • Microsoft SQL Server 2000 Standard Edition
  • kbnosurvey kbarchive kbbug kbfix kbqfe kbsqlserv2000sp1fix KB279293
Feedback