T-SQL Stored Procedure to Report the Last Uptime of an Instance


/*
Stored proc to report uptime of a sql server instance based on the initialization time of its tempdb.

Version 2000+
*/

use master
go

IF EXISTS (SELECT * FROM sysobjects
WHERE name = 'sp__uptime'
AND type = 'P')
DROP PROC sp__uptime

go

create proc sp__uptime
AS
begin
select @@SERVERNAME as ServerName, crdate as LastUpTime
from master..sysdatabases where dbid = db_id('tempdb')
end
go

GRANT EXECUTE ON sp__uptime TO public
go

--Usage
exec sp__uptime
go


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *