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.
Code:
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 Torsten Schuessler on 2008-02-15 at 14:57:34 . Follow any responses to this post through RSS 2.0. |
http://www.insidesql.org/blogs/htsrv/trackback.php?tb_id=135
Schlagwort-Wolke
backup «best practices» books «case study» ctp «cumulative update» datetime dmv ebook exams faq humor index indexoptimize integrity kb learning links loginproperty maintenance «ms sql server 2008» mysql performance php profiler «reporting services» reports reviews serverproperty «service pack» «service pack 3» sharepoint sp_msforeachdb «sql 2008» «sql pass» «sql server» «sql server 2005» «sql server 2008 r2» «sql server builds» sqlcat «sqlpass franken» sqlsrv ssms ssmstoolspack t-sql «technical note» tools training troubleshooting whitepapers




