Microsoft KB Archive/330458

= FIX: A Query That Causes Hash Role Reversal May Return Incorrect Results =

Article ID: 330458

Article Last Modified on 9/27/2005

-

APPLIES TO


 * Microsoft SQL Server 2000 Standard Edition

-



This article was previously published under Q330458





SYMPTOMS
While executing a complex query that involves hash joins on large data sets or on data sets that involve skewed distributions, SQL Server might reverse the roles of the hash build and the probe inputs. In rare circumstances where this role reversal occurs and the original build input is too large to fit in memory and has to be spilled to disk, SQL Server may return an incorrect number of rows.



RESOLUTION
To resolve this problem, obtain the latest service pack for SQL Server 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

290211 INF: How to Obtain the Latest SQL Server 2000 Service Pack

Note The following hotfix was released before SQL Server 2000 Service Pack 3.

The English version of this fix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.   Date         Time   Version        Size             File name -  09-Oct-2002  01:14  2000.80.690.0  7,467,089 bytes  Sqlservr.exe Note Because of file dependencies, the most recent hotfix or feature that contains the files may also contain additional files.



WORKAROUND
To work around this problem, add an &quot;OPTION (LOOP JOIN, MERGE JOIN)&quot; query hint to the affected query.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

This problem was first corrected in SQL Server 2000 Service Pack 3.



MORE INFORMATION
Note The following article discusses a more recent fix for a variation of this problem that is not addressed in the build discussed in this article. The hotfix in KB article 824028 includes a fix for both the variation of the problem and for the issue discussed in this article. Therefore, if the symptoms described in this article apply to you, it is best to apply the fix in article 824028 so that you can benefit from both fixes:

824028 FIX: An Outer or Semi JOIN Query That Results in Hash Role Reversal Followed by a Spill May Return Incorrect Results

To validate the applicability of this hotfix for your scenario, check the following:


 * Use SQL Profiler and capture the EventClass Execution Plan. Check to see if the query that is resulting in incorrect results is using the HASH operator.
 * Use SQL Profiler and capture the EventClass Hash Warning and confirm that this event is raised. If so, make sure that the data column EventSubClass contains &quot;Hash Recursion&quot;. For more information, see the &quot;Errors and Warnings Event Classes&quot; topic in SQL Server Books Online.

Additional query words: hash role reversal

Keywords: kbbug kbfix kbsqlserv2000presp3fix kbqfe kbsqlserv2000sp3fix kbhotfixserver KB330458

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.