Solved

Calculate Size of SQL Server 2008 DB

Posted on 2013-01-14
4
358 Views
Last Modified: 2013-03-07
Hi Experts,
How to calculate total size of SQL Server 2008 DB with breakdown for tables , indexes etc

thank a lot
0
Comment
Question by:juliakir
  • 2
4 Comments
 
LVL 30

Accepted Solution

by:
Brad Howe earned 250 total points
ID: 38774780
Simpe TSQL to get this info for you.

http://gallery.technet.microsoft.com/Determine-size-of-database-6c5373cd


USE BizTalkDTADb --You can change this to desires database
GO

SET NOCOUNT ON
DBCC UPDATEUSAGE(0)
-- DB size.
EXEC sp_spaceused
-- Table row counts and sizes.
CREATE TABLE #t
(
[name] NVARCHAR(128)
, [rows] CHAR(11)
, reserved VARCHAR(18)
, data VARCHAR(18)
, index_size VARCHAR(18)
, unused VARCHAR(18)
)
INSERT #t EXEC sp_msForEachTable 'EXEC sp_spaceused ''?'''
SELECT [name] as 'Table name'
, [rows] as 'Rows'
, cast(replace(reserved, ' KB', '') as bigint) as 'reserved (KB)'
, cast(replace(data, ' KB', '') as bigint) as 'data (KB)'
, cast(replace(index_size, ' KB', '') as bigint) as 'index_size (KB)'
, cast(replace(unused, ' KB', '') as bigint) as 'unused (KB)'
FROM #t
-- # of rows.
SELECT SUM(CAST([rows] AS int)) AS [rows]
FROM #t
DROP TABLE #t
GO


Cheers,
Hades666
0
 
LVL 35

Expert Comment

by:David Todd
ID: 38796005
Hi,

From SSMS, in Object Explorer, Right click on the database, select Reports, select Standard Reports, Select Disk Usage by Table.

Enjoy.

Regards
  David
0
 

Author Comment

by:juliakir
ID: 38911794
David ,
that is nice feature ! What kind of privelegies developer should have in order to be able to do that ?

thank you
0
 
LVL 35

Assisted Solution

by:David Todd
David Todd earned 250 total points
ID: 38912334
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question