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 |
nmtinx
Starting Member
1 Post |
Posted - 2012-04-26 : 15:00:49
|
Dear all,I would like to add a query in my maintenance plan to check all indexes to see whether they have fragmentation > 10 or 30% and then reorganize and rebuild those indexes respectively based on the result. I wonder have anyone done that and can you share your query? I don't want to their standard option to rebuild all indexes no matter what. Thanks. |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-04-26 : 16:11:21
|
Use's Ola's index maintenance script: http://ola.hallengren.com/ |
|
|
JaybeeSQL
Posting Yak Master
112 Posts |
Posted - 2012-04-30 : 12:48:15
|
Anyone have any scripts pertaining to 2000? |
|
|
robvolk
Most Valuable Yak
15732 Posts |
|
JaybeeSQL
Posting Yak Master
112 Posts |
Posted - 2012-05-01 : 07:18:45
|
I should have been more specific, any Select queries that will retrieve fragmentation levels, and that DON'T involve creating procedures (which would require change requests)? |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-05-01 : 09:14:33
|
DBCC SHOWCONTIG will give you fragmentation stats: Link |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2012-05-01 : 12:03:11
|
This is from Book On LineDECLARE @db_id SMALLINT;DECLARE @object_id INT;SET @db_id = DB_ID(N'AdventureWorks');SET @object_id = OBJECT_ID(N'AdventureWorks.Person.Address');IF @db_id IS NULLBEGIN; PRINT N'Invalid database';END;ELSE IF @object_id IS NULLBEGIN; PRINT N'Invalid object';END;ELSEBEGIN; SELECT * FROM sys.dm_db_index_physical_stats(@db_id, @object_id, NULL, NULL , 'LIMITED');END;GO JimEveryday I learn something that somebody else already knew |
|
|
|
|
|