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.
| Author |
Topic |
|
aiken
Aged Yak Warrior
525 Posts |
Posted - 2002-05-02 : 16:46:39
|
| Does anyone have a script to automate running indexdefrag on every index of a table, or every index of every table in a DB? I'll write it myself if not, but I'm hoping to not have to :)Cheers-b |
|
|
izaltsman
A custom title
1139 Posts |
Posted - 2002-05-02 : 17:18:36
|
| All indexes on a table: DBCC DBREINDEX ('tablename') All tables in the db: exec sp_MSforeachtable @command1="dbcc dbreindex ('?') " ---------------Strong SQL Developer wanted in the Boston area. Please e-mail if interested. |
 |
|
|
aiken
Aged Yak Warrior
525 Posts |
Posted - 2002-05-02 : 17:51:20
|
| Except I'm looking for indexdefrag, not dbreindex. You really can't do dbreindex on a production database, at least not on larger tables where you care about performance. indexdefrag doesn't remove and re-create the index (so it's not as complete of a rebuild), but you can do it on tables while users are online.Unfortunately, you have to tell it what index you want rebuilt. It should be a simple matter to build a script to walk through the tables, then walk through the indexes, but I was hoping someone had already done it :)Cheers-b |
 |
|
|
aiken
Aged Yak Warrior
525 Posts |
|
|
|
|
|