?
Solved

SQL 2000 defrag index's

Posted on 2006-12-01
3
Medium Priority
?
670 Views
Last Modified: 2008-03-06
I have a script to defrag some indexes however after building a list an a temp table it does the following to select which indexes to defrag:

SELECT ObjectName, ObjectId, IndexId, LogicalFrag
   FROM #fraglist
   WHERE LogicalFrag >= 25
     AND INDEXPROPERTY (ObjectId, IndexName, 'IndexDepth') > 0

This only returns one row but on inspection there are loads of indexes with a crap scan density, my question is this:

If i remove :

 AND INDEXPROPERTY (ObjectId, IndexName, 'IndexDepth') > 0

And just defrag all of the indexes with fragmentation > 25 will this cause any problems or will this work with out issue. In summary do I need to do the second check on the index properties and if I remove it am I safe to defrag all the indexes?

Cheers
0
Comment
Question by:Netstore
1 Comment
 
LVL 11

Accepted Solution

by:
lluthien earned 2000 total points
ID: 18053044
if you remove the indexdepth check,
you will _not_ skip the systemtables.

so you'd have to figure out another away around that,

   WHERE LogicalFrag >= 25

are you sure you're checking the right fragmentation percentage?

this link has some background info:
http://www.sql-server-performance.com/tp_automatic_reindexing.asp
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question