SQL SERVER – Query to Find ByteSize of All the Tables in Database

SELECT CASE WHEN (GROUPING(sob.name)=1THEN 'All_Tables'
   
ELSE ISNULL(sob.name'unknown'END AS Table_name,
   
SUM(sys.lengthAS Byte_Length
FROM sysobjects sobsyscolumns sys
WHERE sob.xtype='u' AND sys.id=sob.id
GROUP BY sob.name
WITH CUBE

Reference : Pinal Dave (https://darkslategrey-bat-805937.hostingersite.com)

SQL Scripts, SQL Stored Procedure
Previous Post
SQL SERVER – Query to Display Foreign Key Relationships and Name of the Constraint for Each Table in Database
Next Post
SQL SERVER – Auto Generate Script to Delete Deprecated Fields in Current Database

Related Posts

Leave a Reply