Tuesday, June 26, 2012

Get Top Biggest Table in SQL Database



CREATE TABLE #tmpTable
      (
      [name]      VARCHAR(255),
      [rows]      INT,
      [reserved] VARCHAR(100),
      [data]      VARCHAR(100),
      [index_size]      VARCHAR(100),
      [unused] VARCHAR(100)
      )

--_DEFAULT_VendorJournalAccts 4          16 KB 8 KB  8 KB  0 KB
EXEC sp_MSforeachtable @command1=" Insert into #tmpTable EXEC sp_spaceused '?'"

SELECT TOP 100 * FROM #tmpTable
ORDER BY Data DESC

DROP TABLE #tmpTable

No comments: