Saturday, February 25, 2012

Adding indexes to tables

I have a database on Server A and i copy the database over to Server B. But since the data on the database is transformed (I add new columsn to eacht able in the db) during the transfer, I simply transfer the data and nothing else.

Once the transfer is complete I want to add all the indexes on each table in the original db. How would i do that?Why don't you transfer the entire tables, with indexes, and then add your columns?

blindman|||Originally posted by blindman
Why don't you transfer the entire tables, with indexes, and then add your columns?

blindman

Because the indexes i want to add must include the columns i'm adding.|||Originally posted by vmlal
Once the transfer is complete I want to add all the indexes on each table in the original db. How would i do that?

Well then your statement isn't true..they're new indexes and yo need to build them...create a sql script modify them and run...

don't know of an automated way...|||How can the indexes from the tables in the original DB include the columns you are adding? That makes no sense.

You are going to need to write a script that adds whatever indexes you want, and then run the script after you modify your unindexed tables.

blindman|||Yeah i have to add new indexes incl the new columns but all the other indexes excl. the new columns need to be added. i have a scripts to add the new indexes.

Sum of the existing indexes have to be dropped before the new indexes can be added. But is there a way to aleast get the old indexes back?|||If you can come up with a logical way to tell SQL Server what indexes you want to keep and what indexes you don't, then you MAY be able to do this programmatically. Otherwise, SQL Server doesn't have a clue what you want to do.

Write a script. It is the best way to handle this.

blindman

No comments:

Post a Comment