/*
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
Leave a Reply