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

Count table size in SQL Server


Database Database 
Ratings:
0 Comment(s)
 2003  View(s)
Rate this:

Count table size in SQL Server

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


Don't want to miss updates? Please click the below button!

Follow MindStick