At some point you might need to know, how many tables you have in database, number of rows in each table, size of table and indices. Following is a simple SQL Script which can provide you a snapshot of all such details.


 Declare @TabName Varchar(100)

Create table #TempTable (Name varchar(100), Rows int,Reserved varchar(25),Data varchar(25),Index_size varchar(25),Unused varchar(25))
 
Declare TableList cursor LOCAL FAST_FORWARD FOR     
SELECT Name FROM sysobjects
WHERE xtype='U'
ORDER by Name
OPEN TableList     
     
FETCH NEXT FROM TableList INTO @TabName         
WHILE @@fetch_status = 0        
 BEGIN   
        INSERT INTO #TempTable Exec sp_spaceused @TabName
        FETCH NEXT FROM TableList INTO @TabName   
 End
CLOSE TableList
DEALLOCATE TableList
SELECT * FROM #TempTable

Signature

Comments

6/2/2007 7:39:52 AM #

shubhavani

useful procedure. Thanks.

shubhavani India

9/4/2010 9:20:56 AM #

Michal Ditto

I've long read any weblogs anymore simply because as well a lot of websites had been either uninteresting or not recent. Or at worst, each. Here it can be unique, the website is thrilling and informative. Thank god you will discover still such sites for the net. Then yet again it can be really worth browsing.

Michal Ditto United States

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



About Me

Me Hello,my name is Vishwa Mohan Kumar.
I am a Software Architect. This blog is result of my experiments.

Flickr Photos

Calendar

<<  September 2010  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar

Recent Comments

Comment RSS

Live Traffic Feed