SQL Server/T-SQL Tutorial/System Functions/sp spaceused
Версия от 13:46, 26 мая 2010; (обсуждение)
Report on each table using sp_spaceused
3>
4> DECLARE @AWTables TABLE (SchemaTable varchar(100))
5> DECLARE @TableName varchar(100)
6>
7> WHILE (SELECT COUNT(*) FROM @AWTables)>0
8> BEGIN
9> SELECT TOP 1 @TableName = SchemaTable FROM @AWTables ORDER BY SchemaTable
10> EXEC sp_spaceused @TableName
11> DELETE @AWTables WHERE SchemaTable = @TableName
12> END
13>
14> WHILE (1=1)
15> BEGIN
16> PRINT "1 --- 1"
17> IF 1=1
18> BEGIN
19> PRINT "Break up now."
20> BREAK
21> END
22> ELSE
23> BEGIN
24> CONTINUE
25> END
26> END
27> GO
1 --- 1
Break up now.
sp_spaceused reviews the space used by a table in a database.
You can also displace the disk space reserved and used by an entire database.
The syntax is
sp_spaceused [tablename[,@updateusage={TRUE�FALSE}]]