Unanswered: How to export space report to web page or Excel from T-SQL script
I have the t-sql script that generates database report of space used for 200 databases on MS SQL Server 2000. How can I dump the contents of this report to an Excel spreadsheet and/or a Web page html file?
-- Space Usage report for MS SQL Server 2000 databases
EXEC sp_msforeachdb @command1="use [?] exec sp_spaceused"
it's kind of ugly for this query, because each call to sp_spaceused returns two different record sets.
However you can force it into excel by setting "results to text" in QA and then choosing comma delimited, and finally uncheck the "include column headers" setting in QA. at least I think that setting exists in QA. I know it exists in SSMS.
then just execute the result to text, copy paste into a .csv file, open in excel.
If I were you though, I might cosider cracking open the sql of sp_spaceused and creating my own sproc that returns one record set per db, instead of 2. that would be more appropriate for a csv.
How would I do this? I am an Oracle DBA and not too experienced on SQL Server 2000. How would I dump the contents of the stored proc to a flat file or to Excel? Do I need to use xp_cmdshell? Is there a way to generate a web page report within SQL Server 2000 of all the database sizes and space usage?