Walter Meester
HoogkarspelNetherlands
General information
Forum:
Microsoft SQL Server
Environment versions
SQL Server:
SQL Server 2012
>>The optimizer is not always able to optimize a query in the optimal way if you set the parameters in the script. Usually this does go ok when using parameterized Queries.
>>
>>Perhaps eliminating the OR with IN() resolves the problem
>
>Thanks for the suggestion but this was tested an hour ago with same result.
ok, let me ask the question. Why are you setting the values in the script? Can't you set the values through parameters (instead of using variables)? SQL server is able to do parameter sniffing and use that to optimize the plan.
If you have to do it through a script it might be an idea to use the sp_executesql stored procedure which in itself will start another optimization round.
Walter,
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only