SQL Server queries all table names and rows and space usage for data

Source: Internet
Author: User
Tags reserved

Querying all table names select name from sysobjects where xtype= ' u '
SELECT name, object_id, principal_id, schema_id, parent_object_id, type, Type_desc, Create_date, Modify_date, Is_ms_sh ipped, is_published,
Is_schema_published, lob_data_space_id, filestream_data_space_id, max_column_id_used, Lock_on_bulk_load, Uses_ansi_ Nulls, is_replicated,
Has_replication_filter, is_merge_published, is_sync_tran_subscribed, Has_unchecked_assembly_data, Text_in_row_ Limit
Large_value_types_out_of_row
From Sys.tables

Querying all table names and rows in the database
SELECT A.name, B.rows
From Sys.sysobjects as a INNER JOIN
Sys.sysindexes as B on a.id = b.ID
WHERE (B.indid in (0, 1)) and (A.type = ' u ')
ORDER by A.name, B.rows DESC

Query all indication and space consumption \ line number
SELECT object_name (ID) as TableName, 8 * reserved/1024 as reserved, RTRIM (8 * dpages) + ' KB ' as used, 8 * (Reserved -Dpages)/1024x768 as unused,
8 * dpages/1024-rows/1024 * minlen/1024 as free
From sys.sysindexes
WHERE (indid = 1)
ORDER by tablename, reserved DESC

SQL Server queries all table names and rows and space usage for data

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.