Following simple script will help you to find out how long has your SQL Server been running since last startup. Please make note of that this script use tempdb information to calculate the server running time and tempdb system database is recreated every time the server restarts.
1 2 3 4 5 6 7 |
SELECT SERVERPROPERTY(N'MachineName') AS [Server Name], @@SERVERNAME AS [SQL Server Instance], create_date AS [Server Started] , CAST(DATEDIFF(s, create_date, GETDATE()) / 86400.0 as INT) AS No_of_Days FROM sys.databases WHERE name = 'tempdb'; |
Leave a Comment