Checking the running time since last SQL-Server instance startup
Below script will query sys.dm_exec_sessions to find out how long the SQL-Server instance is running.
DECLARE @elapsed_time AS DATETIME, @lr_start_time AS DATETIME SELECT @lr_start_time = (SELECT last_request_start_time FROM sys.dm_exec_sessions WHERE session_id=1) SELECT @elapsed_time = GETDATE()- @lr_start_time SELECT DATEDIFF(day,0,@elapsed_time) AS 'DAYS', DATEPART(hour,@elapsed_time) AS 'HOURS', DATEPART(minute,@elapsed_time) AS 'MINUTES', DATEPART(second,@elapsed_time) AS 'SECONDS', DATEPART(millisecond,@elapsed_time) AS 'MILLISECONDS'
And the result is:
DAYS HOURS MINUTES SECONDS MILLISECONDS ----------- ----------- ----------- ----------- ------------ 41 19 9 17 297
CU
tosc
Print article | This entry was posted by tosc on 2008-02-15 at 14:57:34 . Follow any responses to this post through RSS 2.0. |
Tag cloud
backup «best practices» books bug configuration ctp «cumulative update» demo denali dmv ebook humor index indexoptimize integrity kbfix loginproperty maintenance «ms sql server 2008» performance php profiler «reporting services» reviews «service pack» «service pack 2» «service packs» sharepoint «sql 2012» «sql pass» «sql server» «sql server 2005» «sql server 2008 r2» «sql server 2012» «sql server 2014» sqlcat sqlpass «sqlpass franken» ssms ssmstoolspack sysadmin «system views» t-sql «technical note» tempdb tools «trace flag» troubleshooting upgrade whitepapers