标签:查询表占用空间大小
DECLARE
@sql AS NVARCHAR(300),
@schmeaname AS sysname,
@tablename AS sysname;
DECLARE C CURSOR FAST_FORWARD FOR
SELECT table_schema,table_name
FROM INFORMATION_SCHEMA.tables
WHERE table_type = ‘BASE TABLE‘
OPEN C
FETCH NEXT FROM C INTO @schmeaname,@tablename;
WHILE @@FETCH_STATUS = 0
BEGIN
SET @sql =
N‘EXEC sp_spaceused N‘‘‘
+ QUOTENAME(@schmeaname) + N‘.‘
+ QUOTENAME(@tablename) +N‘‘‘;‘;
EXEC(@sql);
FETCH NEXT FROM C INTO @schmeaname,@tablename;
END
CLOSE C;
DEALLOCATE C;
本文出自 “数据领域” 博客,请务必保留此出处http://charlist.blog.51cto.com/1616209/1697478
标签:查询表占用空间大小
原文地址:http://charlist.blog.51cto.com/1616209/1697478