blog

Home / DeveloperSection / Blogs / Count table size in SQL Server

Count table size in SQL Server

AVADHESH PATEL3429 14-Feb-2013

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


Updated 18-Sep-2014
Avadhesh Kumar Patel District Project Manager - Aligarh 14 months work experience in Panchayati Raj Department Sector as District Project Manager & 12 months work experience in IT Sector as Software Engineer. :-)

Leave Comment

Comments

Liked By