SELECT ........
FROM .....
JOIN .....
JOIN .....
JOIN .....
JOIN .....
JOIN .....
WHERE .....
..... (GROUP, HAVING, ETC.)
AND t.SomeColumn IN ( many thousands of values separated by commas )
Error message:
The query processor ran out of internal resources and could not produce a query plan.
This is a rare event and only expected for extremely complex queries or queries that reference a very large number of tables or partitions.
Please simplify the query.
If you believe you have received this message in error, contact Customer Support Services for more information.
Cause and solution:
the cause and the solution is written in msdn:
Explicitly including an extremely large number of values (many thousands of values separated by commas) within the parentheses, in an IN clause can consume resources and return errors 8623 or 8632.
To work around this problem, store the items in the IN list in a table, and use a SELECT subquery within an IN clause.
So, bottom line:
1. create table #ATmpTable (SomeColumn nvarchar(16) )
2. insert into #ATmpTable (SomeColumn ) values ('204025191')
* many thousands of values insertion...
3. Select with join to the temp table:
SELECT ........
FROM .....
JOIN .....
JOIN .....
JOIN #ATmpTable tmp on t.SomeColumn = tmp.SomeColumn
JOIN .....
JOIN .....
JOIN .....
WHERE .....
..... (GROUP, HAVING, ETC.)
No comments:
Post a Comment