August 23, 2005 at 12:54 pm
Hello,
I have deployed a SQL Server 2000 database with minimum index creation.
Now I need to ship some new indexes to speed up these database.
When I use Enterprise Manager to gerenate SQL Script of this database (and enable Index script option) it generates also the Table creation scripts.
I can run this because the database is running with important data and this script also suppose that all indexes don't exist on the database.
My question is:
How can I script ONLY all my Database Indexes script with DROP for existing ones and without drop/create their Tables?
Regards,
Fernando.
Fernando Malard
August 23, 2005 at 2:58 pm
You can script the indexes one at a time (yawn) in Query Analyser, without getting the tables scripted. I can't see how you can do this in one step for all indexes in a database, or even for a table.
On the other hand, going back to the script generated by EM, what about doing a find and replace? Replace
'CREATE TABLE' with '/*'
and replace
' [PRIMARY]
GO' with '*/' (or whatever text always appears at the end of your CREATE TABLE statements)
and this will comment out all of the CREATE TABLE bits!
Regards, Phil
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
August 24, 2005 at 1:14 am
Go to GEnerate SQL script wizard in the EM
Seelct relevant tables
click on the formatting tab and uncheck all
go to options tab and check Indexes
You will have a nice script to create all the indexes withuot anything else
don't worry about checking for the existing onesm becasue if they are already existing create index will fail for them but continue for the rest.
August 24, 2005 at 1:35 am
Yeah, that works, good thinking. Obviously if an index definition has changed, the 'check for existing' is necessary as you'd want to replace the one that's there currently.
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply