Basic: what's the size on disk of my MS SQL Server DB?
More: can I quickly see where the data is? i.e. which tables, logs, etc
|
|
|||||||||||
|
|
You'll probably want to start with the sp_spaceused command. For example: sp_spaceused Returns information about the total size of the database sp_spaceused 'MyTable' Returns information about the size of MyTable Read the docs for all the things you can get information about. You can also use the sp_msforeachtable command to run sp_spaceused against all tables at once. Edit: Be aware the command sometimes returns multiple datasets, each set containing a different chunk of stats. |
|||||||
|
|
There are several descriptions of how to do it from the GUI. Real DBA's know: GUI's are for chumps. sp_helpdb Returns a recordset of all of the file names, locations, space on disk, and type. You can also retrieve the file names from each databases's sysfiles table. |
|||
|
|
|
The easiest way (no typing!): In SQL 2005/8 from Management Studio, right click the database, select Reports, Standard Reports, Disk Usage (also By Top Tables, Table and Partition). |
|||
|
|
|
This is a query/view that gets all of this info, and more, without any "evil" cursors or loops. ;-)
Enjoy. |
|||
|
|
|
This script loops through all of the tables in the current database and shows how much space each one takes up for data, indexes, and unused space: http://sqlserverpedia.com/wiki/Calculate_Current_Table_Sizes |
|||
|
|
|
run this to get the size per table:
taken from Robert Caine blog This code is for Microsoft SQL 2005+ |
|||
|
|
|
You can see the physical files in
|
|||
|
|
|
Run Start\ Programs\ Microsoft SQL Server\ Enterprise Manager. Open Database sheet, in property %databasename% you can see location Data filrs & Transaction files. |
|||
|