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 ctp «cumulative update» datetime demo dmv ebook humor index indexoptimize integrity kbfix maintenance «ms sql server 2008» performance php «reporting services» reviews rtm serverproperty «service pack» «service pack 2» «service pack 3» «service packs» sharepoint sp_msforeachdb «sql 2012» «sql pass» «sql server» «sql server 2005» «sql server 2008 r2» «sql server 2012» «sql server 2014» «sql server builds» sqlcat sqlpass «sqlpass franken» ssms ssmstoolspack «system views» t-sql «technical note» tempdb tools troubleshooting version whitepapers