Query:
update mytable
set mycol = null
where id in (
583048,
583049,
... (50000 more)
)
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.
My query is very simple, how should I write it so it works ok?
Insert the list of values into a #temp
table then use in
on that.
As explained in this answer a large number of IN
values can cause it to run out of stack as they get expanded to OR
See also related connect item
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With