How long is running SQL Server | Backup Server Tips

2:51:00 AM

To know how much time my SQL Server is running, we can mention 3 ways:


  1. Check on sys.sysprocesses the spid = 1, it is an internal process that is created when the SQL Server instance is started.

  1. Check the creation date of the tempdb database. It can be checked in sys.databases on the column create_date.

  1. Look into the ERRORLOG. The first line is logged when the SQL Server is started.

For test purpose, you can check the steps described below before and after restart the SQL Server service.



-- 0.
-- Current date-time
select getdate()
-----------------------
2009-06-03 04:15:27.513
(1 row(s) affected)

/*
1. Using sys.sysprocesses
Here we can see how much time the SQL Server using
the login_time column and sys.sysprocesses
*/


select
login_time as SQLStart,
datediff(mi, login_time, getdate()) Running_in_Minutes,
datediff(hh, login_time, getdate()) Running_in_Hours,
datediff(dd, login_time, getdate()) Running_in_Days
from sys.sysprocesses where spid = 1

Result
SQLStart Running_in_Minutes Running_in_Hours Running_in_Days
----------------------- ------------------ ---------------- ---------------
2009-06-03 04:13:11.793 2 0 0
(1 row(s) affected)

/*
2. Using sys.databases
Here we can see the column create_date for the
TEMPDB database.
*/


select
create_date as SQLStart,
datediff(mi, create_date, getdate()) Running_in_Minutes,
datediff(hh, create_date, getdate()) Running_in_Hours,
datediff(dd, create_date, getdate()) Running_in_Days
from sys.databases where name = 'tempdb'

Result.
SQLStart Running_in_Minutes Running_in_Hours Running_in_Days
----------------------- ------------------ ---------------- ---------------
2009-06-03 04:13:11.763 2 0 0
(1 row(s) affected)

/*
3. Using ERRORLOG
Executing the SP xp_readerrorlog, we can see the date and time exactly that SQL Server starts to logged activity.
*/

exec master..xp_readerrorlog

Result.
LogDate ProcessInfo Text
----------------------- ------------ ----------------------
2009-06-03 04:13:08.290 Server Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86)
Oct 14 2005 00:33:37
Copyright (c) 1988-2005 Microsoft Corporation



backup server to cloud, backup server 2012 r2, xenserver vm backup, backup exec server 2012, backup gpo server 2012, backup server software, backup server 2012, barracuda backup server 690, backup server image, backup server service, backup server to onedrive, backup server, backup server linux, backup server veeam, yosemite server backup basic download, barracuda backup server 890, backup server cloud, backup server online, backup server hardware, backup server 2012 to nas, backup server software free, backup server vmware, backup server synology, backup exec server, backup server nas, data recovery raid, raid 5 data recovery, data recovery raid 1, recover data from raid, data recovery raid 5, data recovery raid 0, recover data raid 0, recover data from raid 0 hard drive, recover data raid 5, raid data recovery nyc, raid data recovery toronto, data recovery from raid, data recovery from raid 0, best raid data recovery software, raid data recovery london, raid data recovery cost, raid 5 data recovery tools, raid data recovery los angeles, data recovery from raid 5 disk, data recovery on raid 5, data recovery raid 5 array, recover data raid drive, data recovery raid software, raid data recovery free download,

Artikel Terkait

Previous
Next Post »