1. Query to Find ByteSize of All the Tables in SQL Server :-
SELECT CASE WHEN (GROUPING(sob.name)=1) THEN ‘All_Tables’
ELSE ISNULL(sob.name, ‘unknown’) END AS Table_name,
SUM(sys.length) AS Byte_Length
FROM sysobjects sob, syscolumns sys
WHERE sob.xtype=’u’ AND sys.id=sob.id
GROUP BY sob.name
WITH CUBE
2.Query to find out all database size along with full details:-
Ans. Sp_helpdb — execute this is master database.
3.Query to find out information of logfile and mdf file of a particular database:-
Ans.sp_helpfile -execute this from the database for which you want to check the log & mdf file.
4.Find out full database size in server :-
SELECT sum((size*8)/1024) SizeMB
FROM sys.master_files
GO


Leave a Reply