SQL Server - How to Verify a Server Is Responding Using PING and CLR (C #)

Views: 914
Reading Time: 2 minutes

Hello people,
Good night!

In this post I will demonstrate how to validate by SQL Server if a server is responding to the network using CLR (C #) and the PING class, which simulates a ping request that you make at the DOS prompt in Windows or in the Unix Shell.

In everyday life, I use this function a lot to check if a file-sharing server, for example, is available to write database routine files. Otherwise, I can have my routine trigger an email or even write these files to another directory. We can use this function to create server monitoring as well. Anyway, the possibilities are many, and vary according to your need and creativity.

CLR Function Source Code (C #):

Once compiled into the database, we can use the function like this:
SQL Server - How to check if the machine is powered on check computer server is online ping

SQL Server - How to check if the machine is powered on check computer server is online ping 2

And that's it folks!
Big hug and until the next post.

SQL Server - How to check if the machine is powered on check computer server is online ping

SQL Server - How to check if the machine is powered on check computer server is online ping