What's up doc?
The following SELECT statement displays how long a sql server instance was
up for; SQL Server refreshes the tempdb every time it restarts. To
determine how long a SQL Server instance has been running, we use the
created date of the tempdb.
SELECT
CAST(DATEDIFF(ss,crdate,GETDATE())/60/60/24 AS VARCHAR(4)) + 'd '
+ CAST(DATEDIFF(ss,crdate,GETDATE())/60/60 % 24 AS VARCHAR(4)) + 'hr '
+ CAST(DATEDIFF(ss,crdate,GETDATE())/60 % 60 AS VARCHAR(4)) + 'min '
+ CAST(DATEDIFF(ss,crdate,GETDATE()) % 60 AS VARCHAR(4)) + 'sec' AS
SQL_Server_HAS_BEEN_UP_FOR
FROM MASTER.dbo.SYSDATABASES
WHERE name = 'TempDB';
-By Billy Pang
up for; SQL Server refreshes the tempdb every time it restarts. To
determine how long a SQL Server instance has been running, we use the
created date of the tempdb.
SELECT
CAST(DATEDIFF(ss,crdate,GETDATE())/60/60/24 AS VARCHAR(4)) + 'd '
+ CAST(DATEDIFF(ss,crdate,GETDATE())/60/60 % 24 AS VARCHAR(4)) + 'hr '
+ CAST(DATEDIFF(ss,crdate,GETDATE())/60 % 60 AS VARCHAR(4)) + 'min '
+ CAST(DATEDIFF(ss,crdate,GETDATE()) % 60 AS VARCHAR(4)) + 'sec' AS
SQL_Server_HAS_BEEN_UP_FOR
FROM MASTER.dbo.SYSDATABASES
WHERE name = 'TempDB';
-By Billy Pang
Comments
Post a Comment