Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Defrag a heap?

Status
Not open for further replies.

snootalope

IS-IT--Management
Jun 28, 2001
1,706
US
Using SQL 2005

I just finished using a maintenance plan to defrag all the indexs.. worked well!

However, none of the heaps appear to have been defragmented. Should I be concerned about this? Being fairly new to SQL I'm not aware of the method, if recommend or even possible, to defrag a heap... Is it possible?
 
In order to rebuild or reorganize a table you must have a unique clusterd index. There are 3 ways to correct fragmentation of a heap.

1. create a new unique clusterd index.
2. create a unique clustered index then drop it.
3. Select all the data out into a temp table. then truncate the table and insert the data back in the table from the temp table with and order by clause.



- Paul
- If at first you don't succeed, find out if the loser gets anything.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top