SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Find size of all tables in a database


Find size of all tables in a database

Author
Message
suba.sathyanathan 40131
suba.sathyanathan 40131
SSC-Enthusiastic
SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)

Group: General Forum Members
Points: 119 Visits: 164
Comments posted to this topic are about the item Find size of all tables in a database
hp_dba_uk
hp_dba_uk
SSC-Enthusiastic
SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)

Group: General Forum Members
Points: 181 Visits: 123
I think while this is a good script...the build it report for max storage used by tables is faster if you needed a quick look..

of course the query can be twiked...to see size in mb or gb etc..but then I guess the query used by build in report can be captured by profier and twiked too..

any ideas!!:-P
caoxp930
caoxp930
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 193
good script, but it's not suit SQLServer2005;
hp_dba_uk
hp_dba_uk
SSC-Enthusiastic
SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)

Group: General Forum Members
Points: 181 Visits: 123
it works fine for me using it on 2005...post your errors..
chandu.ade
chandu.ade
SSC-Enthusiastic
SSC-Enthusiastic (164 reputation)SSC-Enthusiastic (164 reputation)SSC-Enthusiastic (164 reputation)SSC-Enthusiastic (164 reputation)SSC-Enthusiastic (164 reputation)SSC-Enthusiastic (164 reputation)SSC-Enthusiastic (164 reputation)SSC-Enthusiastic (164 reputation)

Group: General Forum Members
Points: 164 Visits: 229
The same can be done using sp_msforeachtable
See below script
---------------------------------------------------------------------
Create table #tmptblsize
(table_name varchar(50),
rows int,
reserved varchar(50),
actualdatasize varchar(50),
indexsize varchar(50),
unused varchar(50))
EXEC sp_MSforeachtable 'insert into #tmptblsize exec sp_spaceused ''?'''
select * from #tmptblsize
drop table #tmptblsize
--------------------------------------------------------------------
Chandu
mpilchard@gmail.com
mpilchard@gmail.com
SSC-Enthusiastic
SSC-Enthusiastic (120 reputation)SSC-Enthusiastic (120 reputation)SSC-Enthusiastic (120 reputation)SSC-Enthusiastic (120 reputation)SSC-Enthusiastic (120 reputation)SSC-Enthusiastic (120 reputation)SSC-Enthusiastic (120 reputation)SSC-Enthusiastic (120 reputation)

Group: General Forum Members
Points: 120 Visits: 565
That is the same error I see on our 2005 server.

Msg 15009, Level 16, State 1, Procedure sp_spaceused, Line 62
The object 'ComplaintCodes' does not exist in database 'CFS' or is invalid for this operation.
Igor Micev
Igor Micev
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14512 Visits: 5176
Hi,
I used your script and it failed on AdventureWorks2008R2.
The script supplied by chandu.ade works fine. I'm using it on more environments.
Thanks

Igor Micev,
My blog: www.igormicev.com
petes 78713
petes 78713
Grasshopper
Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)

Group: General Forum Members
Points: 15 Visits: 11
To get the scrip to work with AdventureWorks2008R2 I changed the insert into @v_Table to:

Insert Into @v_Table
Select Table_Schema + '.' + Table_Name From Information_Schema.Tables Where Table_Type = 'BASE TABLE'

Unfortunatley sp_spaceused doesn't return the schema!
Peter2012
Peter2012
Mr or Mrs. 500
Mr or Mrs. 500 (536 reputation)Mr or Mrs. 500 (536 reputation)Mr or Mrs. 500 (536 reputation)Mr or Mrs. 500 (536 reputation)Mr or Mrs. 500 (536 reputation)Mr or Mrs. 500 (536 reputation)Mr or Mrs. 500 (536 reputation)Mr or Mrs. 500 (536 reputation)

Group: General Forum Members
Points: 536 Visits: 157
Hi All,

I'm gettting this error from Suba' script.

Errors:
Msg 208, Level 16, State 1, Line 11
Invalid object name 'Information_Schema.Tables'.

Please advise.

Thanks.
suba.sathyanathan 40131
suba.sathyanathan 40131
SSC-Enthusiastic
SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)

Group: General Forum Members
Points: 119 Visits: 164
Hi Peter,

Information_Schema.Tables is a system view. It is available as part of all sql server databases. Kindly let me as to which version of sql server you are using.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search