Sample Header Ad - 728x90

Why when I use variables on SQL the Database Engine avoid the indexes?

2 votes
1 answer
357 views
I'm improving our SSIS process passing the variables through a declare and I found this: Here you have the plan execution using variables brentozar.com/pastetheplan/?id=rkSxs7VPv for the following statement:
select *
from fact_Venta
where Data_ID >= @data1
and Data_ID =@1 
AND [Data_ID]<=@2
As you can see, when I use the declare SQL Database Engine doesn't use the index. The index used is a non-clustered for the column used on the where. Both executions were on the same server, with the same set options and at the same time executed.
Asked by Nacho Gonz&#225;lez Valero (23 rep)
Oct 14, 2020, 07:50 AM
Last activity: Oct 14, 2020, 11:25 AM