Find database size when it is offline

Spread the love

How to find database size when it is offline in SQL server

Hi, Tech Giants! What new to me today? Yeah, We did a SQL Server migration activity or we can say a side-by-side up-gradation activity. From our DBA side, it’s almost done 90%, 10% percent is pending. We have some offline databases in our source server and the decision-making process is going between our big bosses. All of a sudden one of our big bosses asks the total size of all offline databases. Ohhh!! this task I have not done before !! I start googling and found two articles with two TSQL queries. But before googling I was thinking to go to the physical location of the database files and check the size of the files one by one. So I tried all three possibilities and the result shown below.

Solution

Here is a simple TSQL to simplify the work:

Query 1

The first article I found here at sqlservercentral.com

Steps

To run a script on a Microsoft SQL Server using SSMS.

  • Open Microsoft SQL Server Management Studio
  • Select [New Query] from the toolbar
  • Copy the ‘Example Query’
  • Select the database to run the query against
  • Paste the ‘Example Query’ into the query window
  • Click the [Execute] button

Result

Solution

Here is a simple TSQL to simplify the work:

Query 2

The second article I found here seniordba.wordpress.com

Result

And the third method is straightforward. I visit the physical location of the database files and check the size of the files one by one.


Spread the love
Author: OTi
Meet OTi, the brains behind the popular tech blog "OurTechIdeas.com." OTi is an accomplished author, tech enthusiast, and an expert in SQL Server. With over a decade of experience in the tech industry, he has become a trusted voice in the world of database management. OTi's passion for technology began at a young age, and he has been tinkering with computers ever since. He graduated with a degree in Computer Science and has since worked for some of the biggest tech companies in the world. His experience has given him a deep understanding of how technology works and how it can be used to improve our lives.

2 thoughts on “Find database size when it is offline

  1. I’m having the following error when trying to execute Query1:

    Msg 8115, Level 16, State 8, Line 1
    Arithmetic overflow error converting numeric to data type numeric.

Leave a Reply

Your email address will not be published. Required fields are marked *