• try not to hard code your values in the string, else if the code runs with different parameter values, there will be zero plan reuse, unless forced parameterization is enabled.

    Use something like

    EXEC sp_executesql @sql_statement, @Parameters, @parameter1,

    @parameter2

    --Instead of

    exec(@sql_statement)

    I only mention this because it looks like you are trying to successfully embed the scalar value in the dsql.

    Catch-all queries done right [/url]
    Gail Shaw's Performance Blog[/url]