• Hugo Kornelis (2/17/2012)


    cengland0 (2/17/2012)


    I immediately thought of using a hint to force the use of the index. Is that wrong somehow?

    SELECT ID,Col

    FROM FirstTable WITH INDEX(IX_Col)

    WHERE Col = @Get;

    Not wrong, just less good. With this hint, I expect you to get an index scan, which could be a bit better than a scan of the clustered index, but still far worse than an index seek.

    The question is: Can I alter the procedure to do an index seek?

    So, I immediately thought of adding the hint and that would force the use of the index. I then answered Yes to the question without even considering any other ways to cause the index to work naturally by changing the data type for example.

    In other words, I got the question right but not for the reason specified.