I want to generate a script of all the indexes in a database(Create Index).
I don’t want the index script along with create table script. how can we generate it in SQL Server (2005 or 2008). There needs to be separate script for Clustered and Non Clustered Indexes.
This is an excellent article on SQL Server Central that I’ve used.
Here is another that you might like better.
If it’s not exactly what you’re looking for (sorting, filtering) I’m sure it would be easier to edit these than to start from scratch.
Here’s the slightly corrected (2019) code from the first example: