Where Clause

  • Hi,

    I have a where clause which will be used frequently in insert/update/select statements.

    The sql server extracts the records based on the condition in Where Clause.

    Is it sorts records based on the datatype of fields mentioned in "Where" clause?

    Ex:

    Column1 bigint

    Column2 varchar

    Column3 varchar

    Column4 datetime

    Select * From Table1 where

    Column1 = val1 and Column2 = val2 and Column3 = val3 and

    Column4 = val4

    I want to know if i change the positions of fields like

    Select * From Table1 where

    Column4 = val4 and Column1 = val1 and Column2 = val2 and

    Column3 = val3

    Thanks in advance.

    Venkatroyal

  • Order of conditions in a where clause is does not affect performance. SQL will use the best index that it can find, based on parameter values and cardinality, not on the order of the conditions.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply