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
 sp_spaceused - please ignore the xp_fixeddrives

Author  Topic 

tocroi72
Yak Posting Veteran

89 Posts

Posted - 2006-04-19 : 15:35:12
hi,

sp_spaceused return 2 set of results. How do i store this result into a table?

Thanks

druer
Constraint Violating Yak Guru

314 Posts

Posted - 2006-04-19 : 15:42:44
Create table SpaceUsed (field datatype ....)
insert into SpaceUsed
exec (sp_spaceused ...)

Should do it.
Go to Top of Page

tocroi72
Yak Posting Veteran

89 Posts

Posted - 2006-04-19 : 15:46:31
if a sp returns only one set of result , then i can do that , but sp_spaceused return 2 sets of result , i tried as below:
drop table #t
create table #t (database_name varchar (50),database_size varchar(100),[unallocated space] varchar(100)
,reserved varchar(10),data varchar(10),index_size varchar(10),Unused varchar(10))
insert into #t
exec sp_spaceused
and the error message i got is:
Server: Msg 213, Level 16, State 7, Procedure sp_spaceused, Line 148
Insert Error: Column name or number of supplied values does not match table definition.

Thanks
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-20 : 01:01:50
If you want to know the table sizes refer these
http://sqlteam.com/forums/topic.asp?TOPIC_ID=53843
http://sqlteam.com/forums/topic.asp?TOPIC_ID=61762

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2006-04-20 : 05:43:47
Hi tocroi72,

I did this google search...

http://www.google.co.uk/search?hl=en&q=sp_spaceused+temporary+table

...and found this...

http://www.databasejournal.com/features/mssql/article.php/3386661

Search for sp_spaceused on that page, and you have one method to do what you need.

Ryan Randall
www.monsoonmalabar.com London-based IT consultancy

Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page

tocroi72
Yak Posting Veteran

89 Posts

Posted - 2006-04-20 : 11:01:55
Thank you for all of yours suggestion. They are very helpful.

Go to Top of Page
   

- Advertisement -