database Defragmenting

i need a  query, for Defragmenting  database in sql 2005 ?
not for only indexs

Who is Participating?
Aneesh RetnakaranConnect With a Mentor Database AdministratorCommented:
Okay, then Use DBCC INDEXDEFRAG, which Defragments clustered and secondary indexes of the specified table or view.Unlike DBCC DBREINDEX (or the index building operation in general), DBCC INDEXDEFRAG is an online operation. It does not hold locks long term and thus will not block running queries or updates.

Éric MoreauSenior .Net ConsultantCommented:
If you have a clustered index, you don't need to defrag it as all records of your database are in that physical order. You may consider scheduling a maintenance plan to re-index and delete empty spots in the tables
mekusharim_ltdAuthor Commented:

but i need to defrag the database  .

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Aneesh RetnakaranDatabase AdministratorCommented:
Hello mekusharim_ltd,

>but i need to defrag the database  .

I think you are looking for REINDEXING


Aneesh R
mekusharim_ltdAuthor Commented:
the "DBCC REINDEX" do defrag  to all database without locks ??
mekusharim_ltdAuthor Commented:
can i do Defragments to table, not to index ??

i think the DBCC DBREINDEX do only index
Aneesh RetnakaranDatabase AdministratorCommented:
if you have the Clustured index defined on the table , then DBCC INDEXDEFRAG will do the trick, otherwise there is no otherway.
now if you wanna reclaim the  space which you were using for some text / nvarchar/ varchar columns, which you deleted, then you can use DBCC CLEANTABLE  to reclaim the space
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.