SQL Server View SQL statement for data table footprint

Source: Internet
Author: User

1 Declare @name varchar( +)2 Declare @sql varchar( +)3 4 if object_id('tempdb: #space') is  not NULL Drop Table#Space5 Create Table#Space(Namevarchar( -), Rowsbigint, reservedvarchar( A), datavarchar( A), index_sizevarchar( A), unusedvarchar( A))6 7 DeclareSpcursorLocal for Select '['+Name+']'  fromsysobjectswhereType= 'u'8 OpenSP9 FetchSp into @nameTen  while @ @fetch_status = 0 One begin A Set @sql = 'INSERT INTO #space exec sp_spaceused' + @name - exec(@sql) - FetchSp into @name the End - CloseSP -  - Select *  from#Space Order  by cast(Replace(Reserved,'KB',"') as int)desc

From: SQL Server Technology product Group (250942633) group Friends

I independent blog: http://www.haoyuncn.net/sql-server-space

SQL Server View SQL statement for data table footprint

Related Article

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.