Data size of all tables in MSSQL

Source: Internet
Author: User
Declare @ tablespaceinfo table (nameinfo varchar (50), rowsinfo int, reserved varchar (20), datainfo varchar (20), index_size varchar (20), unused varchar (20 )) declare @tablename varchar (255); declare info_cursor cursor for select [name] From sys. tables where type = 'U '; open parameter fetch next from info_cursor into @ tablename while @ fetch_status = 0 begin insert into @ tablespaceinfo exec sp_spaceused @ tablename fetch next from info_cursor into @ tablename end close info_cursor limit select *, convert (varchar, (cast (replace (reserved, 'kb', '') as INT) + Cast (replace (datainfo, 'kb','') as INT) + Cast (replace (index_size, 'kb', '') as INT) + Cast (replace (unused, 'kb','') as INT )) /(1024*1024) + 'G' as totaldata from @ tablespaceinfo order by cast (replace (reserved, 'kb', '') as INT) DESC

Baidu. The source is unknown.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.