This article was previously published under Q299470
This article has been archived. It is offered "as is" and will no longer be updated.
BUG #: 350899 (SHILOH_BUGS)
A SELECT query that uses the DISTINCT function, which includes a self table join (joining a table to itself) by using nested loops, may fail with the following error message:
Error: 1203, Severity: 20, State: 1 Process ID 51 attempting to unlock unowned resource PAG: 8:1:797..
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 theMicrosoft Knowledge Base:
290211 INF: How to Obtain the Latest SQL Server 2000 Service Pack
Force a different join type for the self-join such as a hash or merge join. In some cases, the problem may not occur if the table is reorganized by rebuilding an existing clustered index or adding a clustered index.
Microsoft has confirmed that this is a problem in SQL Server 2000. This problem was first corrected in SQL Server 2000 Service Pack 1.
Analyze the estimated execution plan for the query by using Query Analyzer or the SET SHOWPLAN statement to determine if the self-join operation is using a nested loop join.
The following is an example of a query that may encounter this problem: