How to calculate the total memory occupied by the database

1.8k views Asked by At

I am using sqlserver 2008, How can I calculate the total memory occupied by the Database with tables (>30) and also data in it.

I mean if I have DB (DB_name) and with few tables(tblabc, tbldef......) with data in it, how to calculate the total memory occupied by the database in the server.

Kindly Help me.

Thanks

Ramm

2

There are 2 answers

5
Svetlozar Angelov On BEST ANSWER

See the sizes of mdf and log files

EDIT: Sql Server stores its db in mdf files(one or multiple). You need the lof file too. See where your db is stored and these files are files you need.

Be aware that if you are using FILESTREAM, the actual files are not in the db (mdf)

EDIT2:Books Online When you create a database, you must either specify an initial size for the data and log files or accept the default size. As data is added to the database, these files become full.

So, there is a file with some size even if you have no data..

By default, the data files grow as much as required until no disk space remains. ... Alternatively, SQL Server lets you create data files that can grow automatically when they fill with data, but only to a predefined maximum size. This can prevent the disk drives from running out of disk space completely.

If data is added (and there is no more space in the file)the file grows, but when it is deleted, it keeps its size, you need to shrink it...

0
Jonas Elfström On

I suppose that you refer to disk space and not memory. That would be very hard to get correct since you would have to know exactly how SQL Server stores the data, indexes and so on. Fortunately you do not have to calculate it, just fire up Microsoft SQL Server Management Studio. Right click on your database->Reports->Disk usage.