SELECT CASE WHEN (GROUPING(sob.name)=1) THEN 'All_Tables'
ELSE ISNULL(sob.name, 'unknown') END AS Table_name,
SUM(sys.length) AS Byte_Length
FROM sysobjects sob, syscolumns sys
WHERE sob.xtype='u' AND sys.id=sob.id
GROUP BY sob.name
WITH CUBE
Reference : Pinal Dave (http://blog.SQLAuthority.com)
SQL SERVER – Query to Find ByteSize of All the Tables in Database
November 10, 2006 by pinaldave
Posted in SQL, SQL Authority, SQL Query, SQL Scripts, SQL Server, SQL Stored Procedure, SQL Tips and Tricks, T SQL, Technology | 4 Comments
4 Responses
Leave a Reply
About Pinal Dave
Pinalkumar Dave is a Microsoft SQL Server MVP and a Mentor for Solid Quality India. He has written over 1100 articles on the subject on his blog at http://blog.sqlauthority.com. He is a dynamic and proficient Principal Database Architect, Corporate Trainer and Project Manager, who specializes in SQL Server Programming and has 7 years of hands-on experience. He holds a Masters of Science degree and a number of certifications, including MCDBA and MCAD (.NET). He was awarded Regional Mentor for PASS Asia.
-
Blog Stats
- 10,703,018 Readers
SQLAuthority Links

My Homepage
My Resume
My Other Blog
--------------------
Top Downloads
PDF Downloads
Script Downloads
Script Bank
Favorite Scripts
All Scripts - 1
All Scripts - 2
Top Articles
Best Articles
Favorite Articles - 1
Favorite Articles - 2
--------------------
SQL Interview Q & A
SQL Coding Standards
SQL FAQ Download
--------------------
Jobs @ SQLAuthority
Top 7 Commenters
350 - Imran Mohammed
133- Brian Tkatch
53 - Jacob Sebastian
48 - Tejas Shah
47 - Jerry Hung
46 - Kuldip Bhatt
36 - Ashish GilhotraCategories
- About Me (61)
- Best Practices (90)
- Business Intelligence (14)
- Data Warehousing (30)
- Database (267)
- DBA (124)
- MVP (97)
- Poll (5)
- Readers Contribution (37)
- Readers Question (44)
- Software Development (66)
- SQL Add-On (91)
- SQL Backup and Restore (54)
- SQL BOL (10)
- SQL Coding Standards (20)
- SQL Constraint and Keys (50)
- SQL Cursor (28)
- SQL Data Storage (45)
- SQL DateTime (37)
- SQL Documentation (217)
- SQL Download (222)
- SQL Error Messages (125)
- SQL Function (124)
- SQL Humor (25)
- SQL Index (93)
- SQL Interview Questions and Answers (57)
- SQL Joins (63)
- SQL Optimization (63)
- SQL Performance (219)
- SQL Puzzle (25)
- SQL Security (119)
- SQL Server DBCC (42)
- SQL Server Management Studio (28)
- SQL Stored Procedure (100)
- SQL String (19)
- SQL System Table (50)
- SQL Trigger (24)
- SQL User Group (48)
- SQL Utility (126)
- SQL White Papers (34)
- SQLAuthority (368)
- SQLAuthority Author Visit (80)
- SQLAuthority Book Review (18)
- SQLAuthority News (338)
- SQLAuthority Website Review (28)
- SQLServer (74)
- Tech (905)
- Pinal Dave (895)
- SQL Scripts (527)
- Technology (1145)
- SQL (1145)
- SQL Authority (1145)
- SQL Query (1145)
- SQL Server (1145)
- SQL Tips and Tricks (1145)
- T SQL (1145)
-
Top Posts
- SQL SERVER - Insert Data From One Table to Another Table - INSERT INTO SELECT - SELECT INTO TABLE
- SQL SERVER - Insert Multiple Records Using One Insert Statement - Use of UNION ALL
- SQL Server Interview Questions and Answers Complete List Download
- SQL SERVER - Import CSV File Into SQL Server Using Bulk Insert - Load Comma Delimited File Into SQL Server
- SQL SERVER - Retrieve Current Date Time in SQL Server CURRENT_TIMESTAMP, GETDATE(), {fn NOW()}
- SQL SERVER - Convert Text to Numbers (Integer) - CAST and CONVERT
- SQL SERVER - 2005 - Create Script to Copy Database Schema and All The Objects - Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects
- SQL SERVER - 2008 - Interview Questions and Answers Complete List Download
- SQL SERVER - Restore Database Backup using SQL Script (T-SQL)
- SQL SERVER - 2005 List All Tables of Database
- SQL SERVER - Shrinking Truncate Log File - Log Full
- SQL Server Interview Questions and Answers - Part 1
-
Authors
-
pinaldave
- SQLAuthority News – Data Compression Strategy Capacity Planning and Best Practices
- SQLAuthority News – SQL PASS Summit, Seattle 2009 – Day 4
- SQLAuthority News – SQL PASS Summit, Seattle 2009 – Day 3
- SQLAuthority News – SQL PASS Summit, Seattle 2009 – Day 2
- SQLAuthority News – SQL PASS Summit, Seattle 2009 – Day 1
- SQLAuthority News – 3 Year Old Blog – PASS Summit 2009 – 10.5 Million Views
- SQL Authority News – Advanced T-SQL with Itzik Ben-Gan – Solid Quality Mentors
- SQLAuthority News – New PASS President Rushabh Mehta
- SQLAuthority News – India Market and Third Party SQL Server Tools
- SQLAuthority News – Birds-of-a-Feather (BOF) Lunch – SQL PASS Summit, Seattle, 2009
-
Archives
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
Pages
Category Cloud
About Me Best Practices Database DBA MVP Pinal Dave Software Development SQL SQL Add-On SQL Authority SQLAuthority Author Visit SQLAuthority News SQL Documentation SQL Download SQL Error Messages SQL Function SQL Index SQL Joins SQL Optimization SQL Performance SQL Query SQL Scripts SQL Security SQLServer SQL Server SQL Stored Procedure SQL Tips and Tricks SQL Utility Technology T SQL



how i can find? please reply
1.What is the current file system size of the database?
2. What is the current size of the tables (used)?
@Sandhu
You can find it through two ways
a) Query Analyzer.
b) SSMS/Enterprise Manager.
a). Query Analyzer :
1. Sp_helpdb — execute this is master database.
Output : you will get information about all databases sizes.
2. sp_help ”database_name” —
Output: gives in detail information about Log and data file, with their sizes.
2. Sp_helpfile ( execute in the database for which you want size). Will give the same information about log and data file of the current database.
b) Enterprize manager: Expand Sql Server – Expand databases- click on database name = right click on database name – view – all task and then you can see in detail information about the size of the log file and also data file. And also you can see how much is filled, how much is empty.
b) in Enterprise Manager – right click database name , click properties, you will see the database size.
c) SSMS (2005) : Right click database select reports- click standard reports – Disk usage. you will see a report and you can see all details about sizes. If you expand the last point ” Disk usage by datafiles” you can see some good information.
d) SSMS (2005) – Right click database name, click properties and you can see database size.
To see the only logspace for all databases. Execute this statement,
DBCC SQLPERF( logspace)
Output: Will give you detail information about Logfile of the database.
your second question about tables:
Please visit this link : http://blog.sqlauthority.com/2008/07/08/sql-server-find-space-used-for-any-particular-table/
Hope this helps.
Thanks
Imran.
Good article Thank you :)
Simple & sweet!