Como contornar o SQL Server "O número máximo de tabelas em uma consulta (260) foi excedido."
tenho uma consulta que contém uma série de 21UNIONs
, por exemplo.
CREATE VIEW dbo.USGovCurrencyOnHandBreakdown AS
SELECT ... FROM a
UNION ALL
SELECT ... FROM b
UNION ALL
SELECT ... FROM c
UNION ALL
SELECT ... FROM d
...
UNION ALL
SELECT ... FROM u
A consulta funciona bem quando executada sozinha. Mas quando a consulta é executada na exibição que contém:
SELECT * FROM USGovCurrencyOnHandBreakdown
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 (260) was exceeded.
eu tentei dividir meuUSGovFedExpentiures
visualize em pedaços menores:
CREATE VIEW dbo.USGovCurrencyOnHandBreakdown AS
SELECT x FROM TreasuryAuditResults
UNION ALL
SELECT x FROM USGovCurrencyOnHandBreakdown_Additions
UNION ALL
SELECT x FROM USGovCurrencyOnHandBreakdown_Subtractions
WithUSGovCurrencyOnHandBreakdown_Additions
eUSGovCurrencyOnHandBreakdown_Subtractions
cada um contendo aproximadamente metade das consultas:
CREATE VIEW USGovCurrencyOnHandBreakdown_Additions AS
SELECT ... FROM b
UNION ALL
SELECT ... FROM c
...
SELECT ... FROM k
CREATE VIEW USGovCurrencyOnHandBreakdown_Subtractions AS
SELECT ... FROM l
UNION ALL
SELECT ... FROM m
...
SELECT ... FROM u
Mas selecionando a partir de " parent "a visualização ainda falha:
SELECT * FROM USGovCurrencyOnHandBreakdown
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 (260) was exceeded.
Como posso contornar o limite de 256 tabelas?
Veja tambéFIX: uma consulta Transact-SQL que usa modos de exibição pode falhar inesperadamente no SQL Server 2000 SP3MSDN: especificações de capacidade máxima para o SQL Server