SQL2000 viewing the size of a table

Source: Internet
Author: User

 SQL2000 Viewing the size of a tableTags: sqlsql server database report Tableinsert2011-06-08 11:47 4013 People read comments (0) favorite reports

SQL2000 viewing the size of a table

This article from: http://blog.csdn.net/tianshikuqi8/archive/2011/01/04/6114682.aspx

SQL2000 viewing a table's size collection
Before looking at a huge database, want to delete the useless things inside, reduce the size of the database file, but do not know how or the size of one of the tables, and after some effort finally found how to view the size of the data table in SQL Server 2000 method, in SQL Server 2005, Microsoft has published a report that can be viewed directly, but this report cannot be used with SQL Server 2000.

The following statements are written to return each data table size:

CREATE TABLE TMP (name varchar), rows int,reserved varchar (50),
Data varchar, index_size varchar (+), unused varchar (50))
INSERT INTO TMP (name,rows,reserved,
data,index_size,unused) exec sp_msforeachtable @Command1 = "sp_spaceused '?" --sp_spaceused ' T_vehicle '
SELECT * FROM TMP ORDER BY data desc
DROP TABLE tmp

--Look at a single table, taking up data
sp_spaceused ' Retail11 '

--View all the tables in the entire database take up space but find a table from sysindexes, there will be a small number of data tables (no primary key, no index table)
Select object_name (ID) tablename,8*reserved/1024 Reserved,rtrim (8*dpages/1024) + ' Mb ' used,8* (reserved-dpages)/1024 unused,8*dpages/1024-rows/1024*minlen/1024 free,
rows,* from sysindexes
where indid=1
ORDER BY reserved Desc

--View all the tables in the entire database take up space but it looks like a bit of a hassle.
exec sp_msforeachtable "exec sp_spaceused '?"

SQL2000 viewing the size of a table

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.