Heap Table are Teh Suck
Nicolas Galler | January 30, 2008Today, converted 2 heap tables to clustered ones, and halved the database size. Heap tables get so fragmented that they will have a gigantic amount of unused space. Here is a link to a great script to find out which tables are using up your disk space in SQL server – if the “Unused” space is abnormally large, you may have a fragmentation problem, and one of the best thing you can do is get rid of heap tables, by creating a clustered index or a primary key:
ALTER TABLE Customer ADD PRIMARY KEY (SID);
or
CREATE CLUSTERED INDEX IX_TABLE ON TABLE(COLUMN)
There are a few other ways to defragment tables – but they may not work well (or at all) on heap tables.
PS: If the above script is gone, google “Bill Graziano BigTables”.







