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)
 Store output sp_spaceused into table

Author  Topic 

hvdtol
Yak Posting Veteran

50 Posts

Posted - 2002-07-13 : 12:42:38
Hope somebody can bring me in the right direction.

I want to store the output from sp_spaceused into a table.

Something like

Create table ABC
(field1 char(50)
, field2 char(50)
etc.

insert into ABC
exec master..sp_spaceused

This does not work, because the output from the stored procedure results into more then one line (and row).

Can somebody tell me which technique i should use to do this.

Thanks in advance.

Harry

MichaelP
Jedi Yak

2489 Posts

Posted - 2002-07-14 : 02:19:31
I've never tried anything liek this, but couldf you jsut copy and paste the code out of sp_Spaceused that you need?

That way, you could get just the "first" data set and insert that into your table?

Michael



<Yoda>Use the Search page you must. Find the answer you will.
Go to Top of Page

dsdeming

479 Posts

Posted - 2002-07-14 : 22:12:32
The reason you're not getting the data into your table the way you want is that sp_spaceused returns 2 result set if you don't specify parameters. If you pass in a table name, you get back one row of data which can easily be dropped into a table ( assuming it has the proper structure ) using the execute command. See sp_soaceused in BOL for more info.

Go to Top of Page

hvdtol
Yak Posting Veteran

50 Posts

Posted - 2002-07-15 : 16:23:14
I know i can copy and paste the proc, to create an new proc, but i just want to use this output
Now i weekly execute this proc over all databases, into a txt file.
(using the isql command).
In stead of the txt file i want to store the info into a table.
Using parameters results into getting info about individual tables.
Maybe i will use this output to store into a table.

Thanks!

Go to Top of Page
   

- Advertisement -