All we need is an easy explanation of the problem, so here it is.
- Does the force_legacy_cardinality_estimation hint change cardinality for the whole query (or stored procedure) or just the section of code it’s applied to? (For example, if there are multiple SELECT statements in a Stored Procedure but the hint is only on one of the SELECT statements.)
- Can you use the hint in views?
How to solve :
I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.
The force_legacy_cardinality_estimation hint changes cardinality for a particular statement it is applied to, not for the whole batch or an object (SP, trigger, UDF and so on).
No, you can’t, because the SELECT clauses in a view definition cannot include the OPTION clause.
Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂