Friday 3 May 2019

Check SQL Database size


SQL Query to calculate database size


Below is the query to check the disk space.


SELECT      sys.databases.name as DBName,
            CONVERT(VARCHAR,SUM(size)*8/1024)+' MB' AS [Disk Size]
FROM        sys.databases 
JOIN        sys.master_files
ON          sys.databases.database_id=sys.master_files.database_id
GROUP BY    sys.databases.name
ORDER BY    sys.databases.name


How to check log size and clear log


DBCC SQLPERF(logspace)
DBCC LOGINFO


Below is the query to shrink the log. The first parameter is the log name. you can get the name by pressing the right click on the database and click Properties and then select Files Tab. The second parameter is database size in MB

DBCC SHRINKFILE (ReportServer_log, 8);


No comments:

Post a Comment

How to find the reason of HTTP Error 500.30 - ASP.NET Core app failed to start in Azure App Service

HTTP Error 500.30 - The ASP.NET Core app failed to start If your web app is throwing an error HTTP error 500.30 then how to find the root ca...