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?
Who is Participating?
Alpesh PatelConnect With a Mentor Assistant ConsultantCommented:
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)
sp_msforeachtable 'insert into #temp (name,rows,reserverd, data, index_size, unused)  exec sp_spaceused ''?'''
select * from #temp
Aneesh RetnakaranConnect With a Mentor Database AdministratorCommented:
PortletPaulConnect With a Mentor Commented:
here's a simple script:

in that example the result table is dropped - but that can be amended to suit
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

sameer2010Connect With a Mentor Commented:
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

vivekkumarSharmaConnect With a Mentor Commented:
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
mathburgAuthor Commented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.