FIX: A SELECT Statement with a Large IN Clause May Fail with a Stack Overflow and the Client Disconnects

Article translations Article translations
Article ID: 278421 - View products that this article applies to.
This article was previously published under Q278421
This article has been archived. It is offered "as is" and will no longer be updated.
BUG #: 57729 (SQLBUG_70)
Expand all | Collapse all


A Transact-SQL SELECT statement, which has a large number of elements in the IN clause, may fail with a STACK OVERFLOW exception. In some cases, this problem may cause the client application to disconnect.


To work around this problem:
  • Reduce the number of elements in the IN clause.


  • Rewrite the query to not use an IN clause.


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 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.


With the fix for this problem, a stack overflow exception may still appear in the SQL Server error log. Furthermore, the user may also encounter the following error message:
Msg 8621, Level 17, State 1
Internal Query Processor Error: The query processor ran out of stack space during query optimization.
However, the client application's connection is not dropped under any scenario with this fix. In some cases, the query runs successfully, where in the past a stack overflow exception occurred.


Article ID: 278421 - Last Review: October 21, 2013 - Revision: 2.0
  • Microsoft SQL Server 7.0 Standard Edition
kbnosurvey kbarchive kbbug kbfix kbqfe KB278421

Give Feedback


Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from