Covering index and parameter order

  • I have a covering index on (City, State).

    Is the SQL server engine smart enough to use the covering index on this query:

    SELECT * FROM Table

    WHERE Z.City = @City

    AND Zip = '10016'

    AND Z.State = @State

    Or does the query need to be written with the parameters in the same order as the covering index to get the best results?

    e.g.

    SELECT * FROM Table

    WHERE Z.City = @City

    AND Z.State = @State

    AND Zip = '10016'

    Thanks... I have queries with lots of params and not sure if order matters for the use of covering index.

  • Order of parameters in a where clause does not matter

    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
  • Thanks a lot!

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

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