Solved

How to know database size in SQL?

Posted on 2011-02-28
6
485 Views
Last Modified: 2012-05-11
Hi Experts,

I want to know the size of Primavera database in SQL 2005. Please tell me how thanks
0
Comment
Question by:ragot
6 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 35004615
If you have Management Studio, right-click on the database and then from the context menu choose Reports > Standard Reports > Disk Usage

That will give you a break down of disk usage of your database.
0
 

Author Comment

by:ragot
ID: 35004629
im using sql express only
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35004633
Do you have management studio for SQL Express?
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

Author Comment

by:ragot
ID: 35004640
nope i dont have
0
 
LVL 10

Expert Comment

by:John Claes
ID: 35004702
If you're only using a Query based GUID

You might use the folowing Stored procedure
It gives the information for every Table.

I've added a extra summing query to get the data for the database ;-)


 
CREATE PROCEDURE GetAllTableSizes
AS
/*
    Obtains spaced used data for ALL user tables in the database
*/
DECLARE @TableName VARCHAR(100)      --For storing values in the cursor
DECLARE @TableSchema VARCHAR(100)    --For storing values in the cursor

--Cursor to get the name of all user tables from the sysobjects listing
DECLARE tableCursor CURSOR
FOR 
select sysobjects.[name],sys.schemas.[name]
from sysobjects
INNER JOIN sys.schemas ON sysobjects.uid  = sys.schemas.schema_id 
where  OBJECTPROPERTY(id, N'IsUserTable') = 1
FOR READ ONLY

--A procedure level temp table to store the results
CREATE TABLE #TempTable
(
    tableName varchar(100),
    numberofRows varchar(100),
    reservedSize varchar(50),
    dataSize varchar(50),
    indexSize varchar(50),
    unusedSize varchar(50)
)

--Open the cursor
OPEN tableCursor

--Get the first table name from the cursor
FETCH NEXT FROM tableCursor INTO @TableName, @TableSchema

--Loop until the cursor was not able to fetch
WHILE (@@Fetch_Status >= 0)
BEGIN
    --Dump the results of the sp_spaceused query to the temp table
	declare @TableFullName varchar(201)
	set @TableFullName= @TableSchema + '.' + @TableName
print @TableFullName
    INSERT  #TempTable
        EXEC sp_spaceused @TableFullName

    --Get the next table name
    FETCH NEXT FROM tableCursor INTO @TableName, @TableSchema
END

--Get rid of the cursor
CLOSE tableCursor
DEALLOCATE tableCursor

--Select all records so we can use the reults
SELECT * 
FROM #TempTable

SELECT 
	sum(convert(int,numberofRows)) numberofRows,
	sum(convert(int,substring(reservedSize,0,len(reservedSize)-3))) reservedSize,
	sum(convert(int,substring(dataSize    ,0,len(dataSize    )-3))) dataSize,
	sum(convert(int,substring(indexSize   ,0,len(indexSize   )-3))) indexSize,
	sum(convert(int,substring(unusedSize  ,0,len(unusedSize  )-3))) unusedSize
FROM #TempTable

--Final cleanup!
DROP TABLE #TempTable

GO

Open in new window

0
 
LVL 40

Expert Comment

by:Sharath
ID: 35004829
Run this and see the database_size column value.
exec dbName..sp_spaceused

If your db name is Primavera, then run exec Primavera..sp_spaceused
0

Featured Post

[Webinar] Disaster Recovery and Cloud Management

Learn from Unigma and CloudBerry industry veterans which providers are best for certain use cases and how to lower cloud costs, how to grow your Managed Services practice in IaaS clouds, and how to utilize public cloud for Disaster Recovery

Question has a verified solution.

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

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

864 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now