title: How to rebuild a table in order to free space used by old columns deleted
body: <p>I have a MSSQL clustered index, which I want to rebuild, since I dropped some columns and I want to free space.</p>
  
  <p>In the literature, I have read that, for heaps, you can write</p>
  
  <pre><code>ALTER TABLE myHeap REBUILD;
  </code></pre>
  
  <p>And for clustered indexes:</p>
  
  <pre><code>ALTER INDEX IX_myIndex ON myTable REBUILD;
  </code></pre>
  
  <p>I have two questions:</p>
  
  <p>1) With the index rebuild, will the space previously used by columns deleted be freed? </p>
  
  <p>2) What happens if I call <code>ALTER TABLE myHeap REBUILD;</code> on a clustered table? I tried it and it seems to work, but is this equivalent to writing <code>ALTER INDEX IX_myIndex ON myTable REBUILD;</code> ? Or what is the difference?</p>