Microsoft KB Archive/828269

= FIX: A Transact-SQL query that uses views may fail unexpectedly in SQL Server 2000 SP3 =

Article ID: 828269

Article Last Modified on 3/10/2005

-

APPLIES TO


 * Microsoft SQL Server 2000 Service Pack 3

-





For a Microsoft SQL Server 2000 Service Pack 2 version of this article, see 818406.



Bug #: 469157 (SQL Server 8.0)



SYMPTOMS
When you run a Transact-SQL statement that references many views, the Transact-SQL statement may fail, and you receive the following error message:

&quot;Server: Msg 4414, Level 16, State 1, Line 1 Could not allocate ancillary table for view or function resolution. The maximum number of tables in a query (256) was exceeded.&quot;



Service pack information
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 the Microsoft Knowledge Base:

290211 How to obtain the latest SQL Server 2000 service pack

Hotfix information
The English version of this hotfix 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 ---  26-Feb-2003  03:41  2000.80.777.0     29,244  Dbmslpcn.dll 08-Feb-2003 05:43                   786,432  Distmdl.ldf 08-Feb-2003 05:43                 2,359,296  Distmdl.mdf 30-Jan-2003 01:55                       180  Drop_repl_hotfix.sql 01-Feb-2003 00:32  2000.80.763.0  1,557,052  Dtsui.dll 30-Jan-2003 05:18                   746,470  Instdist.sql 30-Jan-2003 01:55                     1,402  Inst_repl_hotfix.sql 08-Feb-2003 06:40  2000.80.765.0     90,692  Msgprox.dll 01-Apr-2003 02:07                     1,873  Odsole.sql 05-Apr-2003 01:46  2000.80.800.0     62,024  Odsole70.dll 02-Apr-2003 21:48  2000.80.796.0     57,904  Osql.exe 02-Apr-2003 23:15  2000.80.797.0    279,104  Pfutil80.dll 04-Apr-2003 21:27                 1,083,467  Replmerg.sql 04-Apr-2003 21:53  2000.80.798.0    221,768  Replprov.dll 08-Feb-2003 06:40  2000.80.765.0    307,784  Replrec.dll 01-Apr-2003 02:23                 1,084,828  Replsys.sql 24-Apr-2003 23:47                       736  Shortcut to files.lnk 03-Apr-2003 18:14                   104,868  Sp3_serv_uni.sql 19-Mar-2003 18:20  2000.80.789.0     28,672  Sqlevn70.rll 28-Feb-2003 01:34  2000.80.778.0    176,696  Sqlmap70.dll 08-Feb-2003 06:40  2000.80.765.0     57,920  Sqlrepss.dll 05-Apr-2003 01:47  2000.80.800.0  7,540,817  Sqlservr.exe 08-Feb-2003 06:40  2000.80.765.0     45,644  Sqlvdi.dll 26-Feb-2003 03:41  2000.80.777.0     29,244  Ssmslpcn.dll 26-Feb-2003 03:41  2000.80.777.0     82,492  Ssnetlib.dll 17-Mar-2003 14:49                   727,132  Sysmessages.sym 28-Feb-2003 01:34  2000.80.778.0     98,872  Xpweb70.dll Note Because of file dependencies, the most recent hotfix or feature that contains these files may also contain additional files.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section of this article.This problem was first corrected in Microsoft SQL Server 2000 Service Pack 4.



MORE INFORMATION
The maximum number of tables that can be referred in a SELECT Transact-SQL statement is 256. This limit is documented under the &quot;Maximum Capacity Specifications&quot; section of the SQL Server Books Online. This limit includes views and the tables that are referenced in the SELECT statement. Also, the limit includes the tables and the views that are referenced by a view that is included in the query. Therefore, if a table or a view is referenced more than one time in the query, each reference to the table or the view (or the tables and views that are referenced in the view) counts against this limit.

With this fix, the maximum limit of the number of tables or views that are referenced in the query is increased to 260. Therefore, you may still receive the error message that is mentioned in the &quot;Symptoms&quot; section of this article. If you still receive the &quot;Msg 4414&quot; error message, you may have to break up the query so that a lower number of tables or views are referenced in the query. You may change the view definition that is referenced in the problematic query to lower the number of tables that are referenced in the view.

