StorProc Help
Jul 18, 2001Hi All,
I am trying to report the freespace on ALL database in a server (as can be obtained from one database using sp_spaceused). I have adapted the sp_spaceused procedure to give me the following output:
database_name database_size unallocated_space
----------------------------------------------------------
<database name> <value> <value>
I have created a cursor that takes the database name values from sp_databases and then uses the value from the cursor as a variable when executing the sp_spaceused stored proc. To execute in the stored proc this requires the 'USE <database> EXEC master..sp_spaceused.
This gives me the correct information but in the following output:
database_name database_size unallocated_space
----------------------------------------------------------
<database 1 name> <value> <value>
database_name database_size unallocated_space
----------------------------------------------------------
<database 2 name> <value> <value>
database_name database_size unallocated_space
----------------------------------------------------------
<database 3 name> <value> <value>
I am looking for it in the following output:
database_name database_size unallocated_space
----------------------------------------------------------
<database 1 name> <value> <value>
<database 2 name> <value> <value>
<database 3 name> <value> <value>
I tried to output the results of the sp_spaceused (using the curosr variable) into a temporary table to list the results properly, but the query will not allow a ' select @variable <SQL Statement>' with an insert into temp table command!!!