Hi all,
given a certain SQL Server database (2000 or 2005), I need to execute
queries/commands from a .NET app in order to retrieve the following
information:
1) Database size
2) List of tables
3) Each table size
4) List of indexes
5) Each index size
I'd appreciate any advice or pointer.
Many thanks in advance,
TonyHi Tony,
1) sp_helpdb (List all databases) or sp_helpdb DBName (DBNAme information)
2) sp_tables
3) Look in the SQL Server Books online, "Estimating the Size of a Table".
There, you can see some calculations to determine the table size
4) sp_helpindex Table_Name
5) See the point 3), too.
I hope that this helps you.
Cordially,
Richard_SQL
"Tony" wrote:
> Hi all,
> given a certain SQL Server database (2000 or 2005), I need to execute
> queries/commands from a .NET app in order to retrieve the following
> information:
> 1) Database size
> 2) List of tables
> 3) Each table size
> 4) List of indexes
> 5) Each index size
> I'd appreciate any advice or pointer.
> Many thanks in advance,
> Tony
>|||Tony (acangiano@.gmail.com) writes:
> given a certain SQL Server database (2000 or 2005), I need to execute
> queries/commands from a .NET app in order to retrieve the following
> information:
> 1) Database size
sp_helpdb, the first result set.
> 2) List of tables
SELECT name FROM sysobjects WHERE type = 'U' (SQL 2000)
SELECT name FROM sys.tables (SQL 2005)
> 3) Each table size
SELECT object_name(id), reserved *8192/1000000
FROM sysindexes
WHERE indid (0, 1)
ORDER BY 1
This is for SQL 2000. It will run on SQL 2005, but may not give
accurate vales. (I'm not really up to shape on the new metadata
views in SQL 2005.)
> 4) List of indexes
> 5) Each index size
SELECT object_name(id), name, reserved *8192/1000000
FROM sysindexes
WHERE indid > and indid < 250
AND indexproperty(id, name, 'IsHypothetical') = 0
AND indexproperty(id, name, 'IsStatistics') = 0
AND indexproperty(id, name, 'IsAutoStatistics') = 0
ORDER BY 1, name
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Erland Sommarskog wrote:
> sp_helpdb, the first result set. [cut]
Thank you.
Erland and Richard you have been very helpful.
Thanks,
Tony
No comments:
Post a Comment