Internal Query Processor Error: The query processor could not produce a query plan. For more information, contact Customer Support Services.
I was trying to execute the following query:
tbl2ID=(SELECT id FROM dbo.tbl2 WHERE Code=’Code1′)
tbl3ID=(SELECT id FROM dbo.tbl3 WHERE Code=’Code2′)
As you can see, in the above query I’m using two subqueries for getting some keys for use in my main query. In some cases you might get the aforementioned error message. However, this is not always the case as it depends on many factors and not only on the query itself.
Anyway, in order to resolve the issue I just had to re-write the query. The re-written query is the following:
FROM dbo.tbl1 t1, dbo.tbl2 t2, dbo.tbl3 t3
As you can see, I just removed the subqueries and replaced them with additional joins on my main query. Now my query works like a charm!
*** Before changing your query or doing anything else, first, make sure that your instance of SQL Server has the latest service pack installed.
Recommended eBooks on SQL Server: