|
Quite a few times I've worked with groups that couldn't tell you what tables in their database were the largest, or what component (data, indexes, or even unused space) was using the most space. I've pulled around a very simple script for some time that has served me well. SET NOCOUNT ON CREATE TABLE #results(Name sysname,Rows char(11),reserved varchar(18),Data varchar(18),index_size varchar(18),Unused varchar(18)) DECLARE @obj_id int DECLARE @obj_name sysname SELECT TOP 1 @obj_id = id, @obj_name = name FROM sysobjects WHERE ( xtype = 'U') AND id > @obj_id WHILE (@@ROWCOUNT = 1) SELECT TOP 1 @obj_id = id, @obj_name = name FROM
sysobjects WHERE ( xtype = 'U') AND id > @obj_id -- Prune off the "KB" -- Convert to SELECT DROP TABLE #results |
(C) yafla 2006