Is there any way to show how many times the server was restarted this month?

I'm using SQL Server 2008.


  • 2
    By "server" you mean what exactly? SQL Server process? Windows? The physical/virtual machine? Either of these events will be reflected in the event log – mustaccio Aug 24 '18 at 17:09
  • Huum there's way to read the event log from sql server. Maybe we can read it and use count, to count how many "restarts" are there. I will try to remember what query is. – Racer SQL Aug 24 '18 at 17:53
  • Why do you need to know this? Do you have any monitoring tools installed which check that services are running? – Colin 't Hart Aug 25 '18 at 10:27
  • Please remember, if there's an answer that helped you (or provided the most help), to mark it as the accepted answer by clicking the check mark below the vote score, to the left of the answer. – RDFozz Aug 27 '18 at 14:42

Well, I think this can help:

you create a table, insert errorLog data inside this tabel and just select it:

create table ErrorLog ( 
LogDate datetime, 
ProcessInfo varchar(100),
Text varchar(max))

insert into errorlog  EXEC sp_readerrorlog 

select * from errorlog
    where Year(logdate)='2018'
    and text like '%Something%'

Or with a count:

select count(*) from errorlog
        where Year(logdate)='2018'
            and text like '%backup%'

We just need to use a string that is used during a server restart. Maybe '%Server name is%'. I can see this string on every restart.

| improve this answer | |

Yes, to the extent that does not exceed limits that are set.

In SSMS go to Management > SQL Server Logs

Details are in the logs about what happened, but as a quick references, the date shown on each of the log archives is the last entry as the server was shut down.

This is in no way exclusive or fool proof. there are many variables. But if the oldest Archive has a date 3 months ago, the server has not been shut down since then.

enter image description here

Related Keeping all SQL Server logs

| improve this answer | |
  • 2
    To clarify a couple of points - a new errorlog file is started each time SQL Server restarts. If your server has been restarted more times than the number of errorlog files you keep, then that won't be sufficient. Also, you can programmatically start a new errorlog without restarting the server (so the error log does not grow so large that the file becomes difficult to open); if that's being done on the server, then the number of errorlog files alone can't tell you the number of restarts (though if you know when the log is cycled, you can probably make an accurate guess). – RDFozz Aug 24 '18 at 19:37
  • Yeah, that's the problem I saw too @RDFozz. Going with the first answer. Thanks :) – saulob Aug 27 '18 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.