SQL Server View all table sizes, occupied space

Source: Internet
Author: User

    1. Query all database names and their sizes on the machine where the database is located
      2. Query the names and sizes of all tables under the database
      Please expert guidance!


1. View all database related information, parcel storage path, etc.

Use master
SELECT * FROM Dbo.sysdatabases

2.

A case study of SQL2000 's own pubs

execsp_msforeachtable
@precommand=N'CREATE TABLE # # # (
table name sysname,
Record number int,
Reserved space Nvarchar (10),
Using space varchar (10),
The index uses space varchar (10),
Unused space varchar (TEN))',
@command1=N'Insert # # # EXEC sp_spaceused"'?" ",
@postcommand=N'select * FROM # # # ORDER by record number'


Table name record number of reserved space use spatial index use space unused space
Personaltabs 57011 11208 kb 3280 KB 7728 KB (KB)
Roles 8 KB 8 KB 0 KB
Gradetotal 307-KB 0 KB
CHILDSLAVETABLEDTL 0 8 KB 0 KB 8 KB 0 KB
Smspersonalacount 1 KB 8 KB 8 KB 0 KB
Selectdata 169 136 KB-KB (KB)
Maintable_class 7 KB 8 KB 8 KB 0 KB


SQL Server View all table sizes, occupied space

Related Article

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.