Copying indexes from an old database to a new one?

I converted an old SQL Server database from 2000 to 2005 and forgot to add the old indexes to the new db.

Is there a way to copy the old indexes to the new db?

any help?

+2


a source to share


2 answers


You cannot copy indices from one location to another. They must be built in a new location.

You can script delete all your indexes in the old database and transfer them to the new one.



Right click on the database and on the tasks, select "Generate Scripts". Check the box for all objects

and then in options select script indices. Run this script on a new database (it will take a while depending on the size of the tables.

+3


a source


If there are not too many tables, you can create a script from SSMS with all the objects and their indexes in it, and then just drop the CREATE TABLE statements, leaving the indexes.



If you have a large number of tables that you are dealing with, it may be easier to use a tool like Red-Gate "SQL Compare" or Visual Studio Database Edition to compare schemas and generate missing indexes.

+2


a source







All Articles