Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to get contents of sp_spaceused into table?

Author  Topic 

Bill_C
Constraint Violating Yak Guru

299 Posts

Posted - 2009-08-25 : 01:41:44
I would like to copy the contents/results of running 'exec sp_spaceused' into a table, does anyone know how to do this please?

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-08-25 : 01:49:00
declare @tab table(id int, name varchar(64),active bit)
insert into @tab
exec usp_spname value1,value2

select * from @tab

if any input values pass it in value1,value2.........
Go to Top of Page

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-08-25 : 01:52:07
declare @mytable table (objname varchar(100),rows varchar (10),
reserved varchar(10),data varchar(10),index_size varchar(10),
unused varchar(10))



insert into @mytable
exec sp_spaceused '<tablename>'



select * from @mytable

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

Bill_C
Constraint Violating Yak Guru

299 Posts

Posted - 2009-08-25 : 02:03:27
Thanks for that,
how would i get this to return the size of the tempdb?
Go to Top of Page
   

- Advertisement -