• It depends on the way SQL Server processes your query

    We want the SQL Server to process the queries in the following orders

    1. Process the WHERE CLAUSE based on datatype and then

    2. Process the WHERE CLAUSE based on key_value( now dates )

    But, SQL Server might do some calculation which will make it process the query in the reverse order

    This will make SQL Server process the WHERE CLAUSE based on key_value( now dates ) first

    While doing this, it will try to convert all key_values( even non-date values ) to datetime which results in an error

    You can check the execution plan to see what is the case.


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/