I cannot take credit for this code - I found it in another forum and it works for SQL2000 and 2005.

I have 2 questions about modifying it to fit my needs:

First, is there a way to schedule this job in a job and have it write results to a file or perhaps email the results? if so, how would I do that.

Also, How would you modify this to report on individual Database uptime?

Thank you!!

DECLARE @crdate DATETIME, @hr VARCHAR(50), @min VARCHAR(5), @days VARCHAR(5)
SELECT @crdate=crdate FROM sysdatabases WHERE NAME='tempdb'

SELECT @days=(DATEDIFF (dd, @crdate,GETDATE())-1)

SELECT @hr=(DATEDIFF ( hh, @crdate,GETDATE())-@days*24)
IF ((DATEDIFF ( hh, @crdate,GETDATE()))/60)=0
SELECT @min=(DATEDIFF ( hh, @crdate,GETDATE()))
SELECT @min=(DATEDIFF ( mi, @crdate,GETDATE()))-((DATEDIFF( mi, @crdate,GETDATE()))/60)*60
PRINT 'SQL Server ' + CONVERT(VARCHAR(20),SERVERPROPERTY('SERVERNAME'))+' Uptime: '+@days+' days, '+@hr+' hours & '+@min+' minutes'