#sqlhelp

2 NC indexes on the same table:

NC1 - one key col
NC2 - same key col + 4 includes

Select on only the Key Col will always use whichever index was created later.

Any reason for that, or just weird behavior?

SQL2016 SP2
"Always" means in my test, when I create them in either order
More fun...if I force the plan that contains the "correct" index in query Store (which I literally just learned how to do), it does not change anything. Maybe because ad hoc?
You can follow @Kevin3NF.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: