indexes-non clustered

  • Hugo Kornelis (3/24/2016)


    Grant Fritchey (3/24/2016)


    I too am very interested to hear what the full story is on this one.

    My money at this point is on an interview question. Either taken from the internet and then phrased very poorly because the interviewer doesn't know SQL hirself, or reproduced here poorly because the candidate was nervouw and/or in this over hir head.

    From the way the questions have been posed, I'd say that's a pretty safe bet.

  • Grant Fritchey (3/24/2016)


    Hugo Kornelis (3/23/2016)


    In almost 20 years of working with SQL Server, I have only once used an index hint in a production query, and that was after I found that this was the only way to work around a bug; I removed the hint as soon as we had upgraded to the next service pack.

    Same here. The only exception was spatial indexes where we had to hint them, a lot. Other than those, I can't say that I've ever used an index hint anywhere.

    Only time I've used them is for forcing specific behaviour for demos.

    I suspect what's being asked here is how to force an index to get a particular sort order on rows returned from the query.

    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
  • GilaMonster (3/24/2016)


    Grant Fritchey (3/24/2016)


    Hugo Kornelis (3/23/2016)


    In almost 20 years of working with SQL Server, I have only once used an index hint in a production query, and that was after I found that this was the only way to work around a bug; I removed the hint as soon as we had upgraded to the next service pack.

    Same here. The only exception was spatial indexes where we had to hint them, a lot. Other than those, I can't say that I've ever used an index hint anywhere.

    Only time I've used them is for forcing specific behaviour for demos.

    I suspect what's being asked here is how to force an index to get a particular sort order on rows returned from the query.

    Yes, I suspect that too.

    And if I get asked such a question during a job interview, I would react, not respond to the question; and depending on the reaction of the interviewer I would then either walk out or prepare myself for a gig where I will spend more time educating than writing code. (Which BTW is fine)


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • When creating a non-clustered index, each covered column is sorted in ascending order by default, but you can specify optional DESC (decending) or ASC (ascending) keyword following a column's name.

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho

Viewing 4 posts - 16 through 19 (of 19 total)

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