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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 sp_spaceused info.

Author  Topic 

Greg
Starting Member

3 Posts

Posted - 2003-03-13 : 16:38:17
Hello,

I would like to massage the output data from the sp_spaceused procedure.
How do I retreive or save the data in a varible for my next step?

Thanks...

Greg

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-03-13 : 16:44:07
I'm not sure if you are going to be able to do what you are trying to do directly from sp_spaceused, but maybe someone on this forum can help you out on that part. If no one can, then you will have to dive into sp_spaceused and pull out the code parts that you want.

Tara
Go to Top of Page

graz
Chief SQLTeam Crack Dealer

4149 Posts

Posted - 2003-03-13 : 16:47:55
This article (http://www.sqlteam.com/item.asp?ItemID=282) has a hacked up version of sp_spaceused. Probably a good place to start building your own version.

===============================================
Creating tomorrow's legacy systems today.
One crisis at a time.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-03-13 : 16:51:25
How About:

CREATE TABLE SpaceLog (
name sysname, rows int, reserved varchar(255), data varchar(255)
, index_size varchar(255), unused varchar(255))

Declare @TBNAME sysname

Select @TBNAME = 'Table1'

Insert Into SpaceLog (name, rows, reserved, data, index_size, unused) exec sp_spaceused @TBNAME

Select * from SpaceLog
Go

Drop Table SpaceLog
Go



Brett

8-)
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-03-13 : 17:03:22
But that would only work if you are using sp_spaceused with a table. What if you just did sp_spaceused and didn't specify the table name? You get two record sets back, so what how do you do it in this case?

Tara
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-03-14 : 08:46:18
Good Morning.

I would think that if Greg is converned with database level info, the he'll have to open up sp_spaceused and grab from the sproc the code he needs. Since 2 result sets return 2 different number of columns am(way to go microsoft, breaks Codds 1st rule), I don't see how you can insert into a table.

If that's what you're looking for try:

USE MASTER
go

sp_helptext sp_spaceused
Go




Brett

8-)
Go to Top of Page

Greg
Starting Member

3 Posts

Posted - 2003-03-14 : 10:03:15
Good Morning,

You guys are great help... I like to thanks everyone that response to my question. As you may know, it is my first posting. My extended thanks, I don't think it is over done here... :-)

Special thank to Brent. His resolution fit perfectly to my need. I am looking for the statistics data from individual table. Perfect...

Thanks again...

Greg

Go to Top of Page

Greg
Starting Member

3 Posts

Posted - 2003-03-14 : 10:08:23
I am sorry Brett... I even have your name wrong.
It is no excuse. I am sorry.

Have a great day...

Greg

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-03-14 : 14:45:42
My pleasure

Keep on Posting!

Brett

8-)
Go to Top of Page
   

- Advertisement -