Solved

sp_spaceused

Posted on 2013-06-10
6
266 Views
Last Modified: 2013-06-12
I am monitoring my table size using this stored procedure:

sp_spaceused 'tableName'


But, I don't have enough experience to know how to put it into a table in sql so I can monitor trends.  Can you help please?
0
Comment
Question by:mathburg
6 Comments
 
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 100 total points
ID: 39236146
0
 
LVL 48

Assisted Solution

by:PortletPaul
PortletPaul earned 100 total points
ID: 39236286
here's a simple script:
http://www.cryer.co.uk/brian/sqlserver/howto_list_table_sizes.htm

in that example the result table is dropped - but that can be amended to suit
0
 
LVL 13

Assisted Solution

by:sameer2010
sameer2010 earned 100 total points
ID: 39237035
Here is what you can do. Create the table to hold the data and remove drop and create from subsequent executions.
drop table #t
create table #t(name varchar(100),rows varchar(100),reserved varchar(100),data varchar(100),index_size varchar(100),unused varchar(100),currTime datetime default getdate())

insert into #t (name,rows,reserved,data,index_size,unused)
exec sp_spaceused N'avgtable'

select * from #t

Open in new window

0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 21

Accepted Solution

by:
Alpesh Patel earned 100 total points
ID: 39237379
Sorry, Before submit my code someone has already posted.



create table #temp
(
name varchar(max),
rows varchar(max),
reserverd varchar(max),
data varchar(max),
index_size varchar(max),
unused varchar(max)
)
GO
sp_msforeachtable 'insert into #temp (name,rows,reserverd, data, index_size, unused)  exec sp_spaceused ''?'''
GO
select * from #temp
GO
0
 
LVL 2

Assisted Solution

by:vivekkumarSharma
vivekkumarSharma earned 100 total points
ID: 39238152
create table test1_spaceused(name varchar(20),rows int,reserved varchar(20),data varchar(20),index_size varchar(20),unused varchar(20))

insert into test1_spaceused
exec sp_spaceused 'test1'

select * from test1_spaceused
0
 

Author Closing Comment

by:mathburg
ID: 39238512
The last three answered my question well.  
Thank you so much.  aneeshattingal , The link did not work for me.  I'm sure it was probably the same thing sorry.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Server 2012 r2 - Sum totals 2 31
SQL Server 2008 R2, need a pivot/cross tab query... 4 48
What is this datetime? 1 25
SQL syntax question 6 35
Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question