Error "Could not find any index named [IX_MyIndex]" upon creating it

Remove the last line and execute it.

CREATE NONCLUSTERED INDEX [IX_MyIndex] 
ON [dbo].[MyTable] 
([Field1],[Field2]) 
INCLUDE (Fields3, Fields4, Fields5)

It is trying to search index with name - IX_MyIndex which is not available. But after creating an index of name IX_MyIndex you can run the same query.


With the help of Suraj's answer I found that the problem was the option:

DROP_EXISTING=ON

It does not work as I suspected (drop the index IF exists), instead it tries to find it and drop it!

Removing it did the trick!

Tags:

Sql Server