Hi all,
while doing something i have come across something strange.
i have a inline table value function which takes the 1 parameter which get used in the join condition and i have ran the query with 2 approaches and got the result as shown below
Approach 1
select * from Fn_inline_table_udf (41249)
in the above scenario query keeps running and as per query estimated plan it’s not using the index hence it has taken the time .
Approach 2
declare @PREV_SNAPSHOT_DATE_SK_ID AS INT = 41249
select * from Fn_inline_table_udf (@PREV_SNAPSHOT_DATE_SK_ID )
in the above scenario getting the output in 2 sec and as per the plan it make use of index.
I am not able to understand what is the difference between above two approach, due to that in one approach sql is making use of index and not in second. I have also given a thought on implicit conversion hence ran the query with below way as well as
select * from Fn_inline_table_udf (cast(41249 as bigint))
But still function is not returning the result as not using the index again.
does anyone has idea, why sql engine is behaving like that?