473,395 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Get table sizes from DB

code green
1,726 Expert 1GB
My Database is now 75% of its maximum size so pretty soon I will need to do some archiving.
I can view the number of rows and bytes for each table in Enterprise Manager but this is not ideal.
I would like to run a query in SQL Analyzer that returns table name, no of rows, size(bytes) ordered by size.
I assume I need to query information_schema or sysobjects but have little experience with this.
Any help appreciated
May 19 '11 #1
2 2280
ck9663
2,878 Expert 2GB
Here, try checking this out...

Good Luck!!!

~~ CK
May 20 '11 #2
nbiswas
149 100+
Try this

Expand|Select|Wrap|Line Numbers
  1. create table #t(d nvarchar(MAX),t nvarchar(MAX),r int,x nvarchar(100),s nvarchar(100),y nvarchar(100),z nvarchar(100))
  2. declare @s nvarchar(MAX)
  3. set @s=replace('exec [~].dbo.sp_msforeachtable "insert into #t(t, r,x,s,y,z) exec [~].dbo.sp_spaceused !?!"','!',char(39))
  4. EXEC sp_MSForEachDB @command1=@s, @command2="update #t set d='~' where d is null", @replacechar='~'
  5. select d as DbName, t as [table], s as size, r as rows from #t order by Cast(LEFT(s,len(s)-3) as int) desc
  6. drop table #t
Jul 4 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Google Mike | last post by:
This has been discussed before back in 2002, and then in Feb of 2003 when I did a search on Google Groups for MySQL Table Sizes. Back then, people said go here: ...
8
by: jrbareta | last post by:
Is it better to have a table with 10,000 row or 10 tables of 100 rows?
5
by: Anand | last post by:
Hi all Please help me to find out table size in MS-SQL how can I count or identify, this specific table is using some xyz kb of space of my hdd. thanks
34
by: pembed2003 | last post by:
Hi All, Does C++/STL have hashtable where I can do stuff like: Hashtable h<int>; h.store("one",1); h.store("two",2); and then later retrieve them like:
2
by: Ash Man | last post by:
Hi, I have to have only a vertical scroll bar within a table. But when I specify "overflow: auto", it gives both vertical and horizontal scroll bars. Browser used to test is Firefox. How to solve...
2
by: niels.froehling | last post by:
Hy; I converted the tables (for _tabular_ :) data) in a project from the plain <table><tr><td></td></tr></table> structure to seperation into head/foot/body divisions (not the <div>-element)....
21
by: Johan Tibell | last post by:
I would be grateful if someone had a minute or two to review my hash table implementation. It's not yet commented but hopefully it's short and idiomatic enough to be readable. Some of the code...
1
by: Robin9876 | last post by:
In an Access database how is it possible to find table sizes in a database without having to export every table?
139
by: ravi | last post by:
Hi can anybody tell me that which ds will be best suited to implement a hash table in C/C++ thanx. in advanced
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.