• To get a dynamic where clause you would need to use dynamic sql and execute that sql string.

    Or you could have both queries and an if else statement. Based on the conditions you provide, either one or the other query will be executed.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events