Check Index Fragmentation with SQL Server 2000/2005

This post looks at how to check if an index is fragmented in a Microsoft SQL Server table and how to rebuild the index. The advice offered in this post works for both SQL Server 2000 and SQL Server 2005 although the methods are deprecated for SQL Server 2005 and are likely to be dropped in the next release. I will look at the alternate way of doing this for SQL Server 2005 in a later post.