database Defragmenting

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

thanks
mekusharim_ltdAsked:
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.

0
 
É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
0
 
mekusharim_ltdAuthor Commented:
ok,

but i need to defrag the database  .

0
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

DBCC REINDEX


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

i think the DBCC DBREINDEX do only index
0
 
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
0
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.