This blog have to described, how to retrieve table size.

 Below line of code return all table’s size which associated with current database. Steps are given below

Use database

Syntax

USE <Database Name>
e.g.
USE MASTER

Copy and paste below line of code and execute query

USE MASTER 
SELECT CASE WHEN (GROUPING(sob.name)=1) THEN 'All_Tables'
   ELSE ISNULL(sob.name, 'unknown') END AS 'Table Name',
   SUM(sys.length) AS 'Size'
FROM sysobjects sob, syscolumns sys
WHERE sob.xtype='u' AND sys.id=sob.id
GROUP BY sob.name
WITH CUBE

  Modified On Sep-18-2014 01:24:08 PM

Leave Comment