• mcahren - Sunday, December 17, 2017 11:00 AM

    Any ideas?  

    Parameter sniffing doesn't work for the second query. There are several ways to solve this problem you can use plan guides to force the efficient plan or you can use query hint OPTIMIZE FOR @loadperiod = '12'.
    How to use query hints you can read here - https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-query