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 |
ss1011
Starting Member
8 Posts |
Posted - 2009-01-21 : 12:57:20
|
Hi,I'm an "involuntary dba" and would like to get some feedback on the following query that I wrote:use mydbSELECT so.name as 'Table Name' , si.name as 'Index Name', dm.avg_fragmentation_in_percent as 'Average Fragmentation In %'FROM sys.dm_db_index_physical_stats(DB_ID('mydb'), NULL, NULL, NULL , NULL) dm,sys.sysindexes si,sys.sysobjects sowhere si.id = dm.object_idand dm.index_id = si.indidand so.id=si.idand dm.avg_fragmentation_in_percent > 50order by object_id, index_id, avg_fragmentation_in_percent;I think this is giving me what I want which is a list of avg fragmentation > 50 from a particular db (I want the index and the table name to which the index belongs to).Your thoughts?Many thanks.Sid. |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-01-21 : 13:04:12
|
Use Standard Reports within database to get detailed information instead. |
 |
|
ss1011
Starting Member
8 Posts |
Posted - 2009-01-21 : 16:47:51
|
Thanks sodeep...I feel like a dork.:-) |
 |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-01-21 : 19:13:29
|
quote: Originally posted by ss1011 Thanks sodeep...I feel like a dork.:-)
No problem. |
 |
|
|
|
|