1, View a database , Direct execution of stored procedures sp_spaceused that will do
exec sp_spaceused;

2, View a table , Add the table name after the stored procedure
EXEC sp_spaceused 'T_XXXXX';

3, View all tables in the database , You can write a stored procedure , Then execute

The stored procedure is as follows :
============================================= -- explain : Update the size of each table in the query database , The results are stored in the data table --
============================================= CREATE PROCEDURE
[dbo].[P_UpdateTableSpaceInfo] AS BEGIN -- Query whether there is a result storage table IF NOT EXISTS (SELECT *
FROM sysobjects where id = OBJECT_ID(N'temp_tableSpaceInfo') AND
OBJECTPROPERTY(id, N'IsUserTable') = 1) BEGIN -- Create if not present CREATE TABLE
temp_tableSpaceInfo (name NVARCHAR(128), rows char(11), reserved VARCHAR(18),
data VARCHAR(18), index_size VARCHAR(18), unused VARCHAR(18)) END -- Empty data table
DELETE FROM temp_tableSpaceInfo -- Defines the name of the table where temporary variables are stored during traversal DECLARE @tablename
VARCHAR(255) -- Use the cursor to read all table names in the database DECLARE table_list_cursor CURSOR FOR SELECT name
FROM sysobjects WHERE OBJECTPROPERTY(id, N'IsTable') = 1 AND name NOT LIKE
N'#%%' ORDER BY name -- Open cursor OPEN table_list_cursor -- Read the first data FETCH NEXT FROM
table_list_cursor INTO @tablename -- Traversal of the queried table name WHILE @@FETCH_STATUS = 0 BEGIN
-- Check whether the current table is a user table IF EXISTS (SELECT * FROM sysobjects WHERE id =
OBJECT_ID(@tablename) AND OBJECTPROPERTY(id, N'IsUserTable') = 1) BEGIN
-- The current table reads its information and inserts it into the table EXECUTE sp_executesql N'INSERT INTO temp_tableSpaceInfo EXEC
sp_spaceused @tbname', N'@tbname varchar(255)', @tbname = @tablename END
-- Read next data FETCH NEXT FROM table_list_cursor INTO @tablename END -- Release cursor CLOSE
table_list_cursor DEALLOCATE table_list_cursor END GO
implement , see :
EXEC P_UpdateTableSpaceInfo SELECT * FROM temp_tableSpaceInfo;

©2019-2020 Toolsou All rights reserved,
Android Using wechat in H5 Payment result refresh during payment shock !!C++ Can make a sound ! Basic operation of single linked list C Language explanation Java Implement an epidemic number management system 2021 year 11 World programming language ranking linux upper mysql Invalid command _linux lower mysql The command is useless Java project : Campus dormitory management system (java+jsp+javaweb+mysql+ajax) Wechat applet development project directory linux ubuntu Which version ,Ubuntu Which version is the best ?python Code painting cherry blossoms - How to use Python Draw a beautiful cherry blossom