Table size in SQL Sever 2000

5 pts.
Tags:
Database
Database management
Microsoft SQL Server 2000
Please, I need a script to know the size of every tables in my DB. I found that my database is growing above what I expected,and I need to know the size of its tables.

Answer Wiki

Thanks. We'll let you know when a new response is added.

This script will show you the size of all the objects in the database.

<pre>declare @PageSize float
select @PageSize=v.low/1024.0 from master.dbo.spt_values v where v.number=1 and v.type=N’E’

SELECT tbl.name,
@PageSize*((SELECT sum(sidx.dpages)
FROM dbo.sysindexes sidx
WHERE sidx.indid < 2 and sidx.id = tbl.id)
+
(SELECT isnull(sum(sidx.used), 0)
FROM dbo.sysindexes sidx
WHERE sidx.indid = 255 and sidx.id = tbl.id)) AS [DataSpaceUsed]
FROM
dbo.sysobjects AS tbl
INNER JOIN sysusers AS stbl ON stbl.uid = tbl.uid
WHERE
((tbl.type=’U’ or tbl.type=’S’))</pre>

This code is based on the code that Enterprise Manager uses to show you the size of each table.

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following