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;
时间: 2024-10-12 23:45:22