• I think it is quite handy that this can be done in SQL.

    I agree there are other tools that can and have been written already that probably do a much better job of this. However I would ultimately like to log this uptime/downtime somewhere safe and ultimately I think SQL table is a good place for this. This means I can also setup a sql report that can be instantly accessed to show uptime when needed.

    So why use another application to write a program that stores this in SQL when I can just use SQL to do it?

    I note that this script attempts to send an email when the and is failing for me on that point (I think because the profile name you are using is not one that exists on my server). I might suggest alter this to simply display text to show whether it worked or failed

    i.e. if @text is null SELECT 'It failed'