SQL Date Parameter decrease script performance in stored procedure
Good day.
I have narrowed down the issue of my previous post from yesterday. I have created multiple views and created a stored procedure which have 2 paramaters. A date and costcentre field. I have noted that if i fix the date value in the script it will run in 20 seconds. However the moment i add the date parameter and execute the proc it takes forever to run. I have tried casting this field as date and datetime with no effect. In the db the date field is a date data type.
What else can i try to increase the performance to where i fixed the date field to a actual value in the stored procedure
https://www.brentozar.com/archive/2013/06/the-elephant-and-the-mouse-or-parameter-sniffing-in-sql-server/