Share via


Generating Scripts only for Clustered and Non-Clustered indexes in SQL Server 2005

In following cases you will need to generate a scripts for all the clustered and non-clustered indexes on the SQL Server 2005 database:

1. During heavy bulk inserts into a table, you might want to drop all the indexes on the table to make the bulk load process go faster.  Once the bulk load is done you can re-create those indexes back using the scripts.

2. If all the clustered and non-clustered indexes are built on a one single filegroup (PRIMARY, for example) and if you would like to move them to an appropriate filegroup (_DATA and _IDX, for example), you would need both create and drop scripts for clustered and non-clustered indexes.

There is a way to achieve that.   You can download a utility called DBScript from below website:

https://www.codeplex.com/SQLSrvScrpt/Wiki/View.aspx?title=DBScript%20Utility&referringTitle=Home

 

This utility will help you script clustered, non-clustered indexes, foreign keys, and triggers - both CREATE and DROP.