Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Trying to programmatically capture script

Author  Topic 

tcarnahan
Starting Member

23 Posts

Posted - 2011-02-22 : 13:04:18
I have SS2K but am using SSMS. I am attempting to programmatically capture scripts for all Indexes in a development database.

My goal is to programmatically drop all indexes in the database (I have a script that interates all indexes), but I want to be able to easily recreate them as required. This is for a reporting database and the indexes are not keys.

In SSMS, I have tried the following:

- Selected the DB in the Object Explorer
- Right Clicked and selected "Tasks\Generate Scripts"

Unfortunately, it only allows you to script SPs, Tables, Users, and Views ... not indexes.

Would anyone know how to script a DROP and CREATE for all indexes in a database?

Where does SS store the script for Indexes? I have seen the script for SPs in syscomments. Is there an equivalent for Indexes?

Thanks ahead of time for your advice!



MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-02-22 : 13:15:43
may be this is something you are looking for? DBCC DBREINDEX . it rebuilds the indexes for details you can read books online

Cheers
MIK
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-02-22 : 13:49:53
I used the search feature in this site, typed in "SCRIPT INDEXES" and got this

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=156093&SearchTerms=script,indexes

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

tcarnahan
Starting Member

23 Posts

Posted - 2011-02-23 : 05:35:42
quote:
Originally posted by MIK_2008

may be this is something you are looking for? DBCC DBREINDEX . it rebuilds the indexes for details you can read books online

Cheers
MIK



This is a potential, but our DBA has all DBCC actions turned off.
Go to Top of Page

tcarnahan
Starting Member

23 Posts

Posted - 2011-02-23 : 05:41:45
quote:
Originally posted by jimf

I used the search feature in this site, typed in "SCRIPT INDEXES" and got this

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=156093&SearchTerms=script,indexes

Jim

Everyday I learn something that somebody else already knew



Thanks JimF ... I will give this a try when I get to work!
Go to Top of Page
   

- Advertisement -