Showing posts with label sizes. Show all posts
Showing posts with label sizes. Show all posts

Wednesday, March 21, 2012

Scheduled report for database names and sizes

Does anyone has a script which gives all databases names and there
allocated, used sizes in SQLserver2k. I want to schedule this to create a
daily report.

Thanks,
Nasir"Nasir" <nmajeed@.prosrm.com> wrote in message
news:40056fa6$0$43848$39cecf19@.news.twtelecom.net. ..
> Does anyone has a script which gives all databases names and there
> allocated, used sizes in SQLserver2k. I want to schedule this to create a
> daily report.
> Thanks,
> Nasir

Depending on what you need, this may be good enough:

exec sp_MSforeachdb 'exec sp_helpdb ?'
and/or
exec sp_MSforeachdb 'exec ?..sp_spaceused'

Note that this will return multiple result sets, which are awkward to
process within SQL Server itself, although it should be straightforward in a
client script. sp_MSforeachdb is not documented, but you can use your own
cursor instead for production.

Simonsql

Wednesday, March 7, 2012

Schedule mail of DB sizes

Wonder if anyone can help me out here.

I'm trying to set up a job to run overnight that mails me the size of all the databases on SQL Server.

The way I'm getting the size of the db's is by running the following in SQL Query Analyzer...

EXEC sp_MSforeachdb @.command1="print '?' select cast(name as varchar(32)), round(size * 8 / 1.024,3) from ?..sysfiles"

Can anyone suggest a way that I can export the results of this to a text file that can then be mailed to me as part of a scheduled job.

Or can anyone suggest a better/easier way of doing this??

Thanks in advance. :)exec master..xp_sendmail @.recipients = 'recipients '
,@.message = 'message'
,@.query = select cast(name as varchar(128)) "LogicalFileName", (size * 8 / 1024) "Size in MB" from master..sysaltfiles'|||... I'm afraid I've not explained myself properly :(

SQL Mail is not set up on this server, so I need a file creating which I can then ftp to a location from which it can be mailed.

And I'm afraid it's not as simple as setting up SQL Mail, it has to be sent from a different box.

Any suggestions?

Thanks|||Look into isql or osql to execute the query and store results in a file|||Create an DTS package, two data sources, one as your SQL Serv db, one as "Output Text", then create a "transfer" task between the SQL serv and the text file. Edit the transfer task and set the source as "execute sql" and than select the "exec ... " string you are using now.

Then schedule your DTS package as you like it...|||no need for dts here .. simple osql or isql will do the task.|||Thanks Enigma.

Just looking into osql now and that seems to do the trick.